项目三:乘法口诀表
#include<iostream>
using namespace std;
int main()
{
int i,j;
cout<<"***九九乘法口诀表***"<<endl;
for(i=1;i<=9;i++)
{
for(j=1;j<=i;j++)
cout<<j<<"*"<<i<<"="<<j*i<<"\t";
cout<<endl;
}
return 0;
}
项目六:输出星号图
<pre class="cpp" name="code">#include <iostream>
using namespace std;
int main()
{
int i,k,n=6;
for(i=1; i<=n-1; i=i+1)
cout<<" ";
cout<<"*"<<endl;
for(i=2;i<=n-1;i=i+1)
{
for(k=1; k<=n-i; k=k+1)
cout<<" ";
cout<<"*";
for(k=1; k<=2*i-3; k=k+1)
cout<<" ";
cout<<"*"<<endl;
}
for(i=1; i<=2*n-1; i=i+1)
cout<<"*";
return 0;
}
项目七:穷举法解决百钱百鸡问题
#include<iostream>
using namespace std;
int main()
{
int i,j;
double k;
for (i=0;i<=20;i++)
for (j=0;j<=33;j++)
for (k=0;k<100;k++)
if (5*i+3*j+k/3==100 && i+j+k==100)
cout<<"鸡翁"<<i<<"只,"<<"鸡母"<<j<<"只,"<<"鸡雏"<<k<<"只。"<<endl;
return 0;
}