提交时间:2024-05-12 14:07:39
运行 ID: 47087
//枚举 百钱买百鸡 #include<bits/stdc++.h> using namespace std; int main() { int g,m,x; //printf("%5s%5s%5s\n","公鸡","母鸡","小鸡"); cout<<std::left<<setw(5)<<"公鸡"; cout<<std::left<<setw(5)<<"母鸡"; cout<<std::left<<setw(5)<<"小鸡"<<endl; for(int i=1;i<=100/3;i++){ for(int j=1;j<=100-i;j++){ for(int k=1;k<=100-i-j;k++){ if((i*3+j*2+k/3)==100&&(i+j+k)==100&&k%3==0){ //printf("%5d%5d%5d\n",i,j,k); cout<<std::left<<setw(5)<<i; cout<<std::left<<setw(5)<<j; cout<<std::left<<setw(5)<<k<<endl; } } } } return 0; }