项目1:特殊三位数
include<iostream.h>
int jiecheng(int n)
{
int i,m=1;
for(i=n;i>0;i--)
m*=i;
return m;
}
void main()
{
int i,a,b,c;
cout<<"该特殊三位数有:";
for(i=100;i<1000;i++)
{
a=(i/10)/10;
b=(i/10)%10;
c=i%10;
if(jiecheng(a)+jiecheng(b)+jiecheng(c)==i)
cout<<i<<'\t';
}
cout<<endl;
}
<span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">项目2:矩阵求和</span>
<pre name="code" class="cpp">#include<iostream.h>
void main()
{
int a[3][3]={{1,8,9},{3,5,7},{4,6,2}};
cout<<"已知数组为:a[3][3]={{1,8,9},{3,5,7},{4,6,2}}"<<endl;
int i,H1=0,H2=0;
cout<<"两条对角线的和分别为:"<<endl;
for(i=0;i<3;i++)
H1=H1+a[i][i];
cout<<H1<<endl;
for(i=0;i<3;i++)
H2=H2+a[i][2-i];
cout<<H2<<endl;
cout<<"总和为:"<<H1+H2<<endl;
}