10 2013 档案
摘要:#include#include//调用数学函数int main(void) { int x; double y; printf("Enter x:"); scanf("%d",&x); if(x=-2)&&(x2);{ y=sqrt(x*x+x+1);//aqrt为平方根的计算方法 } printf("%lf\n",y); return 0;}
阅读全文
摘要:一、填空:阅读下列程序说明和程序,在可选答案中,挑选一个正确答案。填补(1) (2) (3) (4)处空白,并注释说明为什么。程序说明求 1 + 2/3 + 3/5 + 4/7 + 5/9 + … 的前15项之和。 运行示例:sum = 8.667936程序如下:1 #include 2 void main( )3 {4 int i, b = 1;5 double s;6 s = 0 ;//第一个数为17 for(i = 1; i 2 void main( )3 {4 int i, j, t, a[10];5 printf("Enter 10 integers: ");6
阅读全文
摘要:#includeint main(void){ int a,b,c,h; printf("Enter h:"); scanf("%d",&h); if(h>84){ a++; } else if((h>=60)&&(h0)){ c++; } else(h<0){ printf("error"); } printf("%d%d%d\n",a,b,c);
阅读全文
摘要:#includeint main(void){ int n,i; int a[10]; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n);//输入字符的个数由n定 for(i=0;i<n;i++) scanf("%d",&a[i]); printf("%d",a[i]); return 0;}
阅读全文
摘要:输入n个整数,将它们存入数组a中。输出最大值和它所对应的下标#includeint main(void){ int n,i,a[10],index; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n); //输出n个要求的数 for(i=0;ia[index]) index=i; printf("max is%d\tsub is %d\n",a[index],index); return 0;}
阅读全文
摘要:#includeint main(void){ char n; printf("输入等级: "); scanf("%c",&n); switch(n){ case'A':printf("90-100"); break; case'B':printf("80-89"); break; case'C':printf("70-79"); break; case'D':printf("60-69"); b...
阅读全文
摘要:#includeint main(void){ int choice,i; double price; for(i=1;i<=5;i++){//根据题目要求要循环5次 printf("[1]apples 3.00\n");//输出的价格 printf("[2]pears 2.50\n"); printf("[3]oranges 4.10\n"); printf("[4]grapes 10.20\n"); printf("[0]Exit\n"); printf("Enter cho
阅读全文
摘要:#includeint main(void){ int year,n,i,m; printf("Enter year,m:"); scanf("%d%d",&year,&m); for(i=1;i<=m;i++){ printf("Enter year:"); scanf("%d",&year); } if((year%4==0&&year%100==!0)||(year%400==0)){//年份除以4=0且除以100不等于0或年份除以400等于0 printf(&q
阅读全文
摘要:#include int main(void){ char ch; int blank, digit, i, letter, other; blank = digit = letter = other = 0; printf("Enter 15characters:"); for(i = 1; i = 'a' && ch= 'A' && ch = '0') &&(ch<= '9'))/字符的代号 digit ++; else other ++; } prin
阅读全文
摘要:#includeint main(void){ int n,m,i,sum; double average; printf("Enter m:"); scanf("%d",&m); for(i=1;i<=m;i++){//以此来输入n个学生的成绩 printf("Enter n:"); scanf("%d",&n); sum=n+n; } average=(sum)/m; printf("average=%lf",average); return 0;}
阅读全文
摘要:#includeint main(void){ int y; double x; printf("Enter x:"); scanf("%lf",&x); y=0; if(x>0)y=1; else if(x<0)y=-1; printf("y=%d",y); return 0;}
阅读全文
摘要:#includeint main(void){ double x,y; printf("Enter x:"); scanf("%lf",&x); if(x50);{ y=0.58*x; } printf("y=%lf\n",y); return 0;}
阅读全文
摘要:#includefloat fact(int n);int main(void){ int m,n; float x,y,h; printf("Enter m and n:"); scanf("%d%d",&m,&n); x=fact(m); y=fact(n)*fact(m-n); h=x/y; printf("h=%lf",h); return 0;}float fact(int e){ int i; float p; p=1; for(i=1;i<=e;i++){ p=p*i; } return p;}
阅读全文
摘要:#includedouble fact(int n);int main(void){ int i; double sum; sum=0; for(i=1;i<=100;i++) sum=sum+fact(i); printf("1!+2!+...+100!=%e\n",sum); return 0;} double fact(int n) { int i; double result; result=1; for(i=1;i<=n;i++) result=...
阅读全文