《2013年福建省计算机二级c语言真题及答案(填空题部分)》由会员分享,可在线阅读,更多相关《2013年福建省计算机二级c语言真题及答案(填空题部分)(9页珍藏版)》请在金锄头文库上搜索。
1、2013 填空题答案填空题答案11、 程序 Ccon441.c 的功能是:从键盘输入一个直角三角形的两条直角边 a 和 b,计算并输出其周长和面积。将程序填写完整。#include #include void main()double a,b,c,circle,area;printf(“Input 2 edges:“);scanf(/*/ “%lf %lf“ /*/,c=sqrt(/*/ a*a+b*b /*/);circle=a+b+c;area=/*/ a*b/2 /*/ ;printf(“circle=%lfn“,circle);printf(“area=%lfn“,area);getc
2、h(); 2、 程序 Ccon442.c 求一堆螺栓总数:若以 4 个螺栓一组,则多 2 个;若以 7 个一组,则多3 个;若以 9 个一组,则多 5 个,这堆螺栓最多有几个?#include void main()int i=1, mark;mark=/*/ 1 /*/;doif(i-2)%4=0)2013 填空题答案填空题答案2if(/*/ !(i-3)%7) /*/ )if(!(i-5)%9)printf(“Sum=%dn“,i);mark=0;/*/ i+ /*/;while(mark);getch( );3、 程序 Ccon451.c 中的函数 PrintLetters(int n)
3、的功能是:输出 n 行图形,例如当 n=3 时图形如下:abbbccccc将程序填写完整。#include void main() int n;/*/ void PrintLetters(int n); /*/printf(“Please input n (n=1 and n=1 for(/*/ a=1 /*/; avoid main()float x;int n;double Calculating(int);printf(“Please input n (n=1 and n=1int n=0,i,j;int x;printf(“Input string:“);gets(str);/*/ p
4、=str; /*/2013 填空题答案填空题答案6while(*p!=0)for(i=0; *p=0 for(j=0;jint CountNumber(unsigned long n)/*/ int /*/ counter= 0 ;if(n=0 | n4000000000) return 0; while(n)n/=/*/ 10 /*/;counter+;return counter;void main()unsigned long x;printf(“Pleae input x(x0 and xvoid main()int a,d,n,i;long x,sum;sum=/*/ 0 /*/;p
5、rintf(“a,d,n=“);scanf(“%d,%d,%d“,printf(“Series of Numbers:n“);x=a;for(i=1; ivoid InsertHead(int a,int n,int x)int i;for(i=n-1; /*/ i=0 /*/; i-)ai+1=ai;/*/ a0=x; /*/void main()int data11=1,12,3,14,5,16,7,18,9,10,x,i;printf(“Pleae input x:“);scanf(“%d“,InsertHead(/*/ data,10,x /*/);for( i=0;ilong int fun(long int n)long int s;if(/*/ (n=1) /*/)s=1;elses=n*n+/*/ fun(n-1) /*/;return (s);void main()long int n;printf(“Input n:“);scanf(“%ld“,if(/*/ n30)printf(“%ld is error!n“,n);elseprintf(“Sum=%ldn“,fun(n);getch();红色为答案红色为答案