160809230张钊
#include<stdio.h> int main() { int i,sum=0; sum=0; for(i=1;i<=100;i++) sum+=i; printf("sum=%d\n",sum); return 0; }
#include<stdio.h> int main(){ int n,i,jiec=1; printf("请输入一个整数n:"); scanf("%d",&n); i=n; while(i>1){ jiec=jiec*i; i--; } printf("%d!=%d\n",n,jiec); return 0; }
#include<stdio.h> int main() { int k,sum=0; for(k=1;k<=100;k++) sum+=k; printf("sum=%d\n",sum); for(k=1;k<=50;k++) sum=sum+k*k; printf("sum=%d\n",sum); for(k=1;k<=10;k++) sum=sum+1.0/k; printf("sum=%d\n",sum); return 0; }
#include<stdio.h> int main() { char c; int zm=0,sz=0,kg=0,qt=0; while((c=getchar())!='\n'){ if(c>='a'&&c<='z'||c>='A'&&c<='Z') zm++; else if(c==' ') kg++; else if(c>='0'&&c<='9') sz++; else qt++; } printf("字母个数;%d\n",zm); printf("空格个数;%d\n",kg); printf("数字个数;%d\n",sz); printf("其他个数;%d\n",qt); return 0; }
#include<stdio.h> int main() { int m,n,t,i,gys=1,gbs; printf("请输入两个整数;"); scanf("%d%d",&m,&n); if(n>m){ t=m; m=n; n=t; } for(i=n;i>=1;i--) if(m%i==0&&n%i==0) break; printf("m=%d,n=%d",m,n); if(i!=0){ gys=i; printf(",最大公约数为;%d\n",gys); } gbs=m*n/gys; printf("最大公倍数为;%d\n",gbs); return 0; }