项目一:百钱百鸡问题
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
#include <iostream>
using namespace std;
int main()
{
int x,y,z;
for(x=0;x<=20;x++)
for(y=0;y<=33;y++)
{
z=100-x-y;
if(z%3==0&&5*x+3*y+z/3==100)
cout<<"鸡翁"<<x<<"鸡母"<<y<<"鸡雏"<<z<<endl;
}
return 0;
}
项目二:输出星号图
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
#include <iostream>
using namespace std;
int main()
{
int i,j,k;
for(i=1;i<6;i++)
{
for(j=1;j<=6-i;j++)
cout<<" ";
cout<<"*";
for(k=1;k<=2*i-3;k++)
cout<<" ";
if(i!=1)
cout<<"*";
cout<<endl;
}
for(j=1;j<=11;j++)
cout<<"*";
cout<<endl;
return 0;
}
09-13