This commit is contained in:
xxq250 2024-08-23 14:19:34 +08:00
parent a63e990f6d
commit a889c2c772
9 changed files with 182 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,30 @@
#include<iostream.h>
int main()
{
int i,a,b,c;
float sum,average;
sum=0;
i=0;
average=0;
b=0;
c=0;
cout<<"请输入整数:\n";
cin>>a;
while(a!=0)
{
sum=sum+a;
i++;
if(a>0)
b=b+1;
else
c=c+1;
cout<<"请输入整数:\n";
cin>>a;
}
average=sum/i;
cout<<"有正数:"<<b<<"\n";
cout<<"有负数:"<<c<<"\n";
cout<<"平均值为:"<<average<<endl;
return 0;
}

View File

@ -0,0 +1,14 @@
#include<iostream.h>
int main()
{
int x,a,b,c;
for(x=100;x<1000;x++)
{
a=x/100;
b=(x%100)/10;
c=x%10;
if(x==a*a*a+b*b*b+c*c*c)
cout<<x<<" ";
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include<iostream.h>
int main()
{
int x,sum,a;
for(x=1;x<1000;x++)
{
sum=0;
for(a=1;a<x;a++)
{
if(x%a==0)
sum=sum+a;
}
if(sum==x)
{
cout<<x<<" its factors are ";
for(a=1;a<x;a++)
{
if(x%a==0)
cout<<a<<',';
}
cout<<'\n';
}
}
return 0;
}

View File

@ -0,0 +1,24 @@
#include<iostream.h>
int main()
{
int m,n,a,b,p,q;
cout<<"请输入两个正整数m,n:\n";
cin>>m>>n;
a=m;
b=n;
while(a%b!=0)
{
p=a%b;
a=b;
b=p;
}
for(q=1;q<=m*n;q++)
if((q%m==0)&&(q%n==0))
break;
cout<<"最大公约数:"<<b<<endl;
cout<<"最小公倍数:"<<q<<endl;
return 0;
}

View File

@ -0,0 +1,19 @@
#include<iostream.h>
int main()
{
int i,j,k;
for(i=1;i<=6;i++)
{
for(j=1;j<=(6-i)*2;j++)
{
cout<<' ';
}
cout;
for(k=i;k>0;k--)
cout<<k<<' ';
cout<<'\n';
}
return 0;
}

View File

@ -0,0 +1,19 @@
#include<iostream.h>
int main()
{
int i,j,k;
for(i=1;i<=6;i++)
{
for(j=1;j<i*2;j++)
{
cout<<' ';
}
cout;
for(k=1;k<=(7-i);k++)
cout<<k<<' ';
cout<<'\n';
}
return 0;
}

View File

@ -0,0 +1,20 @@
#include<iostream.h>
#include<math.h>
int main()
{
int Amount,Years;
float yrate,mrate,mpay,tpay;
cout<<"Loan Amount:";
cin>>Amount;
cout<<"Number of Years:";
cin>>Years;
cout<<"Interest Rate"<<' '<<"Monthly Payment"<<' '<<"Totally Payment\n";
for(yrate=0.05000;yrate<=0.08000;yrate=yrate+0.00125)
{
mrate=yrate/12;
mpay=(Amount*mrate)/(1-1/pow((1+mrate),Years*12));
tpay=mpay*12*Years;
cout<<yrate*100<<"%"<<" "<<mpay<<" "<<tpay<<endl;
}
return 0;
}

View File

@ -0,0 +1,30 @@
#include <iostream.h>
int main ()
{
int d,p,h,t,a,b,c,f;
for (d=4;d>=1;d--)
{
for (p=4;p>=1;p--)
{
for (t=4;t>=1;t--)
{
for (h=4;h>=1;h--)
{
a=((d==1)+(h==4)+(p==3));
b=((d==4)+(h==1)+(p==2)+(t==3));
c=((d==3)+(h==4));
f=((d==3)+(h==2)+(p==1)+(t==4));
if (a==1&&b==1&&c==1&&f==1&&d!=p&&d!=h&&p!=h&&p!=t&&h!=t&&t!=d)
{
cout <<"洞庭湖第" <<d <<""<<endl;
cout <<"鄱阳湖第" <<p <<""<<endl;
cout <<"洪泽湖第" <<h <<""<<endl;
cout <<"太湖第" <<t <<""<<endl;
}
break;
}
}
}
}
return 0;
}