2025-7-14
题解参考:
#include <bits/stdc++.h>
using namespace std;
int main(){
int xiaoji;
cout<<setw(5)<<"公鸡"<<setw(5)<<"母鸡"<<setw(5)<<"小鸡"<<endl;
for(int gongji=1;gongji<=33;gongji++){
for(int muji=1;muji<=50;muji++){
xiaoji=100-gongji-muji;
if(gongji*3+muji*2+xiaoji*1.0/3 == 100){
printf("%5d%5d%5d\n",gongji,muji,xiaoji);
}
}
}
return 0;
}
2025-7-16
#include <bits/stdc++.h>
using namespace std;
bool hole[10];
int main(){
for(int i = 0 ; i <10 ; i++){
hole[i] = true; // 是空的洞
}
int n = 0 ;
hole[n] = false;
for(int i = 1 ; i <= 1000 ; i++){ // 次数
n = (n + i) % 10;
hole[n] = false;
// cout << n << endl;
}
for(int i = 0 ; i <10 ; i ++){
if(hole[i])
cout << i << endl;
}
return 0;
}
洞编号从1-10
7-17
使用带标志位进行冒泡排序进行优化、
写出此算法代码