项目1:输出星号图
#include <iostream>
using namespace std;
int main()
{
int i,j,n=6;
for(j=1;j<=n-1;++j)
cout<<" ";
cout<<"*"<<endl;
for(i=2;i<=n-1;++i)
{
for(j=1;j<=n-i;++j)
cout<<" ";
cout<<"*";
for(j=1;j<=2*i-3;++j)
cout<<" ";
cout<<"*"<<endl;
}
for(j=1;j<=2*n-1;++j)
cout<<"*";
cout<<endl;
return 0;
}
项目
5
:百钱百鸡问题
#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;
}