main() { int a[3][3],sum1=0,sum2=0,i,j; printf("\ninput the numbers:\n"); for(i=0;i<=2;i++) for(j=0;j<=2;j++) scanf("%d",&a[i][j]); for(i=0;i<=2;i++) for(j=0;j<=2;j++) { if(i==j) sum1=sum1+a[i][j]; if(i+j==2) sum2=sum2+a[i][j];} printf("%d,%d",sum1,sum2); } |
#include<stdio.h> printf("input scores:\n"); for(i=0;i<5;i++) |
程序源代码: 猴子吃桃问题.猴子第一天摘下若干个桃子,当即吃了一半,还不过瘾,又多吃了一个.第二天早上又将剩下的桃子吃掉一半,又多吃了一个.以后每天早上都吃了前一天剩下的一半零一个.到第10天早上想再吃时,就只剩一个桃子了.求第一天共摘多少桃 |
一球从100m高度自由落下,每次落地后反跳回原高度的一半,再落下.求它在第10次落地时,共经过多少米?第10次反弹多高? 程序源代码: main() { float sn=100.0,hn=sn/2; int n; for(n=2;n<=10;n++) { sn=sn+2*hn;/*第n次落地时共经过的米数*/ hn=hn/2; /*第n次反跳高度*/ } printf("the total of road is %f\n",sn); printf("the tenth is %f meter\n",hn); } |
程序源代码: main() { int n,t,number=20; float a=2,b=1,s=0; for(n=1;n<=number;n++) { s=s+a/b; t=a;a=a+b;b=t; } printf("sum is %9.6f\n",s); } |
程序源代码: main() { float n,s=0,t=1; for(n=1;n<=20;n++) { t*=n; s+=t; } printf("1+2!+3!...+20!=%e\n",s); } |
#include <stdio.h> main() { char c; int zimu=0,kongge=0,shuzi=0,other=0; printf("请输入一行字符:\n"); while((c=getchar())!='\n') { if(c>='a' && c<='z' || c>='A' && c<='Z') zimu++; else if(c==' ') kongge++; else if(c>='0' && c<='9') s |
#include <stdio.h> ======================== C语言源程序 计算键盘输入字符的个数 |
1、求下面算术表达式的值 2、写出下面程序的结果 3、写出下面表达式运算后a的值 |
请输入任意一个三位整数,求其各位平方之和 如:输入156,求得是1*1+5*5+6*6 |
============================ 请输入一个华氏温度f,输出其摄氏温度c C=5/9*(f-32) ===== |
用C语言或汇编求解1+2+3+...+100=? #include<stdio.h> main() #include"stdio.h" |
#include<stdio.h> |
发表评论 评论 (0 个评论)