福建省计算机等级考试二级编程题附答案
福建省计算机等级考试(二级C语言)上机考试试题题库汇编〈华侨大学学生可参考〉

福建省计算机等级考试(二级C语言)上机考试试题题库汇编一、选择题(每套共20小题,每题2分,共40分)(50100) 在C语言中,合法的字符常量是()。
(A) '字' (B) "A" (C) "ABC" (D) '\x41'(50119) ()不属于结构化程序设计的三种基本控制结构。
(A) 选择结构 (B) 循环结构(C)嵌套结构 (D) 顺序结构(50120) 函数是C源程序的基本单位,一个函数由函数的首体和()两部分组成。
(A)函数体 (B) 语句体 (C) 结构体 (D) 联合体(50121) 能将C源程序转换为目标程序的软件是()。
(A) 汇编程序(B)编译程序 (C) 编辑程序 (D) 解释程序(50122) 下列叙述正确的是()。
(A)注释部分可在C源程序单独占一行,也可跟在一行语句后面(B) 花括号"{ }"只能用作函数体的定界符(C) 函数是C源程序的基本单位,所有函数名都可以由用户命名(D) 分号是C语句之间的分隔符,并不表示一条语句的结束(50123) C源程序的基本单位是()。
(A) 子程序 (B) 复合语句 (C) 过程 (D)函数(50200) C语言的下列运算符中,优先级最高的运算符是()。
(A) ++ (B) += (C) || (D) !=(50219) 整型常量没有()形式。
(A)二进制 (B) 八进制 (C) 十进制 (D) 十六进制(50220) 合法的长整型常量是()。
(A) 6246245 (B) 1E10 (C) 0L (D) (Long)6246245(50221) 合法的字符常量是()。
(A) '\' (B) 'xx' (C) '\\' (D) "x"(50222) 正确的常量是()。
(A) 'a3' (B) 1E6.1 (C) E-3 (D) "\0"(50223) 合法的用户标识符是()。
福建省计算机二级VB设计题目含答案

ListBox 相关属性:;;在属性窗口中设置列表框的list属性,按ctrl+回车表示输入下一个项目相关代码如下:Private Sub C1_Click()Form1.Picture =LoadPicture("k:\fjexam95\jztx.bmp") End Sub Private Sub C2_Click()Form1.Picture = LoadPicture("") End Sub标签控件属性:;;滚动条控件属性:;;;菜单编辑器按钮:将菜单降级为子菜单按钮:相关代码如下:Private Sub Add_Click()Label1.Caption = Val(Text1.Text) + Val(Text2.Text) End SubPrivate Sub Sub_Click()Label1.Caption = Val(Text1.Text) - Val(Text2.Text) End Sub Private Sub Clean_Click() Label1.Caption = "" Text1.Text = ""Text2.Text = ""End Sub相关代码如下:Private Sub Command1_Click() Text1.Visible = FalseEnd SubPrivate Sub Command2_Click() Text1.Visible = TrueText1.Text = "VB程序设计"End SubPrivate Sub Form_Click() Timer1.Interval = 0End Sub Private Sub Timer1_Timer()L1.Caption = L1.Caption + 1End Sub标签控件属性:名称---L1Caption---0,BorderStyle---1计时器控件属性:Interval---2000Shape 控件属性:;;;;Form 属性:Private Sub Command1_Click() Timer1.Interval = 500End Sub Private Sub Timer1_Timer()If Val(Text1.Text) > 0 Then Text1.Text = Text1.Text - 1 If Text1.Text = 0 Then Timer1.Interval = 0End SubPrivate Sub Command1_Click() List2.AddItem List1.TextEnd Sub Private Sub Command2_Click()MsgBox "你共选修了" & List2.ListCount & "门课程"End Sub 相关属性:;;Private Sub Form_Load() Timer1.Enabled = False End Sub Private Sub Command1_Click() Timer1.Enabled = TrueEnd SubPrivate Sub Command2_Click()Label1.Caption = "00:00:00" Timer1.Enabled = False End Sub Private Sub Timer1_Timer()Label1.Caption = Format(Time, "hh:mm:ss")End SubPrivate Sub Command1_Click() Picture1.ClsPicture1.Line (0, 0)-(1800, 1100) End Sub Private Sub Command2_Click() Picture1.ClsPicture1.Circle (900, 550), 300, , , , 2End Sub;Private Sub Command1_Click()Text2.Text = Text1.SelTextEnd SubPrivate Sub Command1_Click()List1.AddItem Text1.TextList2.AddItem Len(Trim(Text1.Text))Text1.SetFocusText1.SelStart = 0Text1.SelLength = Len(Text1.Text)End Sub;;Label控件属性:AutoSize—true;Text属性:Heigh—600;Width—3000;MultiLine---True;ScrollBars—1-Horizontal Private Sub Text1_Change() Text2.Text = Text1.Text End SubPrivate Sub c1_Click()If ch1 And ch2 ThenText1.Text = "报名参加篮球和排球比赛" ElseIf ch1 ThenText1.Text = "报名参加篮球比赛" ElseIf ch2 Then Text1.Text = "报名参加排球比赛" ElseText1.Text = ""End IfEnd SubForm属性:Backcolor:蓝色;标签:Backstyle---0-transparent;Alignment---2-center;Forecolor---红色代码:Private Sub C1_Click()Label1.Caption = "祝考生考试顺利"End SubForm属性:Caption---课程选择ListBox控件属性:Style---1-checkbox;list:“高等数学”“英语”“计算机基础”“大学物理”“思想品德”Private Sub Command1_Click()If Text1.Text = "student" ThenLabel2.Caption = "欢迎使用本系统" ElseLabel2.Caption = "口令错,请重新输入“Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) Text1.SetFocusEnd IfEnd SubText1属性:PassWordChar---*添加Label2,Label3,Label4,Label5.其Caption分为”调出颜色”,”红(R)”,”绿(G)”,”蓝(B)”的标签控件,Label1的Caption 为空,和添加三个水平滚动条(名称为hs1,hs2,hs3),且min,max属性值均为0,255。
(完整)福建省计算机等级考试二级选择题(附答案)

一、单项选择题(1)。
下面程序运行后,文件d_f.dat的内容是(1 )。
main(){ FILE *fp; int i=10,j=20;fp=fopen("d_f.dat","w");fprintf(fp,"%d ”,i);fclose(fp);fp=fopen(”d_f.dat”,”a");fprintf("%d ”,j);fclose(fp);}① 10 20 ② 20 ③ 20 10 ④ 10(2). 若有定义:enum day{sun,mon, tue, wed, thu, fri, sat};,则枚举常量sun、mon的值分别为(4 )。
① 7 0 ② 1 2 ③ 7 1 ④ 0 1(3)。
下列程序段运行后,表达式( 2 )的值为3。
struct point{ int x;int y;} *p;struct point a[3]={1,2,3,4,5,6};p=a;①p[3].x ②p[1]。
x ③ *(p+2)④p[2]。
x(4)。
以下程序段的运行结果是(3 ).int x[]={2,3,4,5,6,7},*p=x;int i,s=0;for(i=1;i〈5;i++) s+=p[i++];printf("%d”,s);① 20 ② 14 ③ 8 ④ 6(5)。
C语言的函数体由( 1 )括起来.①{ } ②[]③〈〉④( )(6). 若有定义:int x,y,z; 语句 x=(y=z=3,++y,z+=y); 运行后,x的值为(2 )。
① 7 ② 6 ③ 8 ④ 3(7). 若有定义:int x;char c=’A'; 则正确的赋值表达式是( 4 )。
(说明:'A'的ASCII 码的十进制值为65,’a’的ASCII码的十进制值为97)①x=’ABC' ②x=c+'ABC’ ③x=c+’CBA' ④ x=c+32(8). 下面叙述错误的是( 3 )。
福建省计算机等级考试二级选择题(附答案)

一、单项选择题(1). 下面程序运行后,文件d_f.dat的内容是(1 )。
main(){ FILE *fp; int i=10,j=20;fp=fopen("d_f.dat","w");fprintf(fp,"%d ",i);fclose(fp);fp=fopen("d_f.dat","a");fprintf("%d ",j);fclose(fp);}① 10 20 ② 20 ③ 20 10 ④ 10(2). 若有定义:enum day{sun,mon, tue, wed, thu, fri, sat} ; ,则枚举常量sun、mon的值分别为(4 )。
① 7 0 ② 1 2 ③ 7 1 ④ 0 1(3). 下列程序段运行后,表达式( 2 )的值为3。
struct point{ int x;int y;} *p;struct point a[3]={1,2,3,4,5,6};p=a;①p[3].x ②p[1].x ③ *(p+2) ④p[2].x(4). 以下程序段的运行结果是(3 )。
int x[]={2,3,4,5,6,7},*p=x;int i,s=0;for(i=1;i<5;i++) s+=p[i++];printf("%d",s);① 20 ② 14 ③ 8 ④ 6(5). C语言的函数体由( 1 )括起来。
① { } ② [ ] ③ < > ④ ( )(6). 若有定义:int x,y,z; 语句 x=(y=z=3,++y,z+=y); 运行后,x的值为(2 )。
① 7 ② 6 ③ 8 ④ 3(7). 若有定义:int x; char c='A'; 则正确的赋值表达式是( 4 )。
(说明:'A'的ASCII码的十进制值为65,'a'的ASCII码的十进制值为97)① x='ABC' ② x=c+'ABC' ③ x=c+'CBA' ④ x=c+32(8). 下面叙述错误的是( 3 )。
2013年福建省计算机二级(c语言真题)编程题

1、 打开程序Cprog441.c ,完成其中的函数fun (x),该函数计算数学表达式:2.1cos sin 2++x e x x的值。
例如:fun (1.65)=6.424#include <stdio.h>#include <math.h>double fun(double x){/**/return (2*sin(x)+exp(x))/(cos(x)+1.2);/**/}void main(){printf("fun(1.65) = %7.3lf\n", fun(1.65));getch();}2、 打开程序Cprog442.c ,完成其中的函数Reverse(unsigned int n),该函数的功能是:返回整数n (1<n ≤10000)的逆向值。
例如:n 为1234时,返回值为4321。
#include <stdio.h>long int Reverse(unsigned int n){/**/int a[5],i,len=0,result=0;while (n!=0){a[len++]=n%10;n/=10;}for (i=0;i<len;i++){result=result*10+a[i];}return result;/**/}void main(){unsigned int a;printf("Input a (1-10000):");scanf("%u",&a);printf("result=%ld\n",Reverse(a));getch();}3、 打开程序Cprog451.c ,完成其中的函数fun(x,n),该函数计算数学表达式:8.0)3x )(12x (3x n++- 的值。
例如:fun(2.3, 5)=9.713#include <stdio.h>#include <math.h>double fun(double x,int n){/**/return 3*pow(x,n)/((2*x -1)*(x+3)+0.8);/**/}void main(){printf("fun(2.3,5) = %7.3lf\n", fun(2.3,5));getch();}4、 打开程序Cprog452.c ,完成其中的函数DecTohex(unsigned int data, int hex[30], int *resultlen),该函数的功能是:将十进制数data 转化为对应的十六进制数,十六进制数的各位依次存储在数组hex 中,*resultlen 保存转化结果的位数。
最新福建省计算机等级考试二级C语言考试题库

最新福建省计算机等级考试二级C语言考试题库改错题#include <stdio.h>#include <string.h>void main(){char s1[100], s2[100];int i,s_len;printf("Please input string: \n");gets(s1);s_len = /**/ s1 /**/;for(i=0; i<s_len; i++){if(s1[i] >= '0' && s1[i] <= '7')s2[i] = s1[i] + 2;else if(s1[i] == '8'/**/ && /**/s1[i]=='9')s2[i] = s1[i]-8;elses2[i] = s1[i];}/**/ s2[i+1] /**/ = '\0'; puts(s2);getch();}#include <stdio.h>#include <math.h>int prime( int x ){int i, mark=1 ;double k;/**/ i=1 /**/;k=(int)sqrt((double)x); while (i<=k){ if(x%i==0){/**/ i=k+1; /**/break;} i++;}return (mark);}void main(){int a;printf("Input a number: ");scanf("%d",&a);if(/**/ !prime(a) /**/)printf("%d is a prime number.\n", a); elseprintf("It's not.\n");getch();}#include <stdio.h>float fun(float a){ return (a*a+2*a+1)/(a-1); }void main(){float x,y,z;float result;printf("\nPlease input x,y,z: "); scanf(/**/ "%d%d%d" /**/,&x,&y,&z); if(x==1 || y==1 || z==1){ printf("Divide 0,error!");getch();return ;}result=/**/ fun(x,y,z) /**/;printf("\nResult=%.2f\n",result); getch();}#include <stdio.h>void chg(char s[]){int i;/**/ i=1 /**/;while(s[i]!='\0'){if ((s[i]>='A' && s[i]<='Z') && /**/ i%2 /**/) /**/ s[i]=s[i]-32; /**/i++;}}void main(){char str_s[100];printf("Enter string: ");gets(str_s);chg(str_s);printf("\nNow string is:");puts(str_s);getch();}#include <stdio.h>int fun(/**/ char p /**/) {int x;/**/ x=1; /**/while(*p){x=x*8+*p-'0';p++;}return(/**/ *p /**/); }void main(){char str_s[6];printf("Enter string: ");gets(str_s);printf("\nDecimal is: %d",fun(str_s) ); getch();}#include <stdio.h>void main(){char str[100];char *p;p=str;scanf("%s",str);while ( /**/*p=='\0' /**/)p++;printf(/**/"The length is: %s "/**/,p-str); getch();}#include <stdio.h>void main(){ int i,gw,sw,sum=0;for(i=1;i<100;i++){sw=i/10;gw= /**/ i-sw /**/;if((gw==3 || gw==5)||(sw==3 || sw==5))/**/ sum=i /**/;}printf("\nThe sum is:%d",sum);getch();}#include <stdio.h>#include <math.h>void fun(/**/ float a, b, c /**/) {double s,area; if(a+b>c && a+c>b && b+c>a){/**/ s=a+b+c/2; /**/area=/**/ sqt(s*(s-a)*(s-b)*(s-c)) /**/ ;printf("area=%7.2f\n",area);}elseprintf("Not a triangle.\n"); }void main(){float a,b,c;printf("Input a,b,c:");scanf("%f,%f,%f",&a,&b,&c);fun(a,b,c);getch();}#include <stdio.h>void main(){int i,num[100],count;/**/ count=1 /**/;for(i=1000; i<=2000; i++)if(/**/ (i-2)%4 = 0 && (i-3)%7=0 /**/) {num[count]=i;count++;}printf("Total number is:%d\n", count ); for(i=0; /**/i<=count /**/;i++)printf("%d\n", num[i]);getch();}#include <stdio.h>void swap(int *p, /**/ *q /**/) {int temp;/**/ *temp /**/= *p;/**/ *q = *p; /**/*q = temp;}void main(){int a,b;printf("Input 2 numbers:\n");scanf("%d%d",&a,&b);printf("\nOriginal: a=%d b=%d\n",a,b); swap(&a,&b);printf("Now: a=%d b=%d\n",a,b);getch();}填空题/**/ /**/<stdio.h>void main(){char str[100];int /**/ /**/;printf("Input string :"); gets(str);for(i=j=0; str[i]!='\0'; i++) {if(str[i]!='b'){str[j]=str[i];/**/ /**/;}}str[j]='\0';printf("Now string is:");puts(str);getch();}#include <stdio.h>void main(){struct student{char name[10];float score;};struct studentstu[5]={"Mary",76.1,"John",87.3,"Tom",81,"susa",87.8,"wilu",79};int i=0,k=0;/**/ /**/ ;for(i=0;i<5;i++)if(stu[i].score>max){ max=/**/ /**/ ;/**/ /**/;}printf("\nname:%s,score:%.2f", stu[k].name,stu[k].score ); getch();}#include <stdio.h>#include <math.h>void main(){ int i,j ;int a[5][5],sum;/**/ /**/;printf("Please input 25 numbers:\n");for(i=0; i<5;i++)for(j=0;j<5;j++){ scanf("%d",&a[i][j]);if(/**/ /**/)sum+=a[i][j];}printf("%.5f\n",/**/ /**/);getch();}#include <stdio.h>void main(){ int i,j,k;int num=0;printf(" No. 1 yuan 2 yuan 5 yuan\n"); for(k=0;k<=2;k++)for(j=0;j<=5;j++)for(i=0;/**/ /**/;i++)if(/**/ /**/){ num++;printf("%9d%9d%9d%9d\n",num,i,j,k);}getch();}#include <stdio.h>/**/ /**/ N 10int find(int a[],int x) {int i;for(/**/ /**/;i<N;i++){if(a[i]==x)return(i);}return (/**/ /**/); }void main(){int a[N]={21,56,-9,0,3,17,18,5,-23,11};int f,f_at;printf("Input a number to be searched:"); scanf("%d",&f);f_at=find(a,f);if(f_at>=0)printf("%d is found,it's at %d\n",f,f_at);elseprintf("Not exist.\n");getch();}#include <stdio.h>void main(){ int m,n,k;for ( m = 1; m < 10 ; m++)for ( n = 1 ;/**/ /**/; n++){ k =/**/ /**/;if (k == 99)printf ( "M = %d N = %d\n", m, n ); }getch();}#include <stdio.h>#define N 10void main(){int a[N]={21,56,-9,0,3,17,18,5,-23,11}; int i,j,/**/ /**/;for(i=N-1;i>=1;i--){for(j=0;j<=/**/ /**/ ;j++){if(/**/ /**/){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}}}printf("Sorted numbers:\n");for(i=0;i<N;i++)printf("%4d ",a[i]);printf("\n");getch();}#include <stdio.h>void main(){int x,na,nb,nc;na=nb=/**/ /**/;printf("Please input integer number, end with 0:\n"); scanf("%d",&x);while( x ){if(x<0)/**/ /**/;else++nb;if( abs(x%/**/ /**/)==3 )++nc;printf("Please input integer number, end with 0:\n"); scanf("%d",&x);}printf("na=%d nb=%d nc=%d\n",na,nb,nc);getch();}#include <stdio.h>void main(){ enum body{zhang,wang,zhao,li};/**/ /**/ body day[12], j;int i;j=zhang;for(i=0;i<12;i++){day[i]=j;j++;if(j>li)j=/**/ /**/;}printf("List :\n");for(i=1;i<=12;i++){switch(day[i-1]){case zhang:printf("Day %2d is %s \n",i,"zhang");break; case wang:printf("Day %2d is %s \n",i,"wang");break; case /**/ /**/:printf("Day %2d is %s \n",i,"zhao");break; case li:printf("Day %2d is %s \n",i,"li");}}getch();}#include <stdio.h>void main(){int i,s[9];float aver;printf("Please input sampler:\n");for(i=0;i<9;i++)scanf("%d",&s[i]);aver=((float)/**/ /**/)/2;for(i=0;i<9;i++)if(s[i]</**/ /**/)printf("%d\n",s[i]);getch();}编程题#include <math.h> #include <stdio.h> double fun(double x) { /**/ /**/}void main(){double x;printf("Pleae input x:");scanf("%lf",&x);printf("\nfun(%6.3lf) = %6.3lf\n",x,fun(x));getch();}#include <stdio.h>#include <string.h>float fun(float f, char s[]) { /**//**/}void main(){ float x,y;char str[16];printf("Input the fahrenheit temperature: "); scanf("%f",&x);y=fun(x,str);printf("the celsius temperature: %f, %s\n",y,str); getch();}#include <math.h> #include <stdio.h> double fun(double x) { /**/ /**/}void main(){double x;printf("Pleae input x:");scanf("%lf",&x);printf("\nfun(%6.3lf) = %6.3lf\n",x,fun(x));getch();}#include <stdio.h> int fun(long a[]) { /**//**/}void main(){int i,n;long a[20];n=fun(a);for(i=0;i<n;i++)printf("%ld ",a[i]);printf("\n");printf("n=%d\n",n);getch();}#include <stdio.h> #include <math.h> double fun(float x) { /**/ /**/}void main(){ float x;double y;printf("Please input a number: "); scanf("%f",&x);printf("f(%.2f)=%.2f\n",x,fun(x)); getch();}#include <stdio.h>long fun(int n){ /**//**/}void main(){int n;printf("Input n(n>=1): ");scanf("%d",&n);printf("fun(%d) =%ld \n ",n,fun(n));getch();}#include <stdio.h>#define RW 3#define CL 5void fun(int a[][CL],int n) { /**//**/}void main(){ int arra[RW][CL] = {{1,2,3,4,5},{11,12,13,14,15},{21,22,23,24,25}}; int i,j,k;printf("Original array is:\n");for(i=0; i<RW; i++){for(j=0;j<CL;j++)printf("%6d", arra[i][j]);printf("\n");}printf("\nInput sites of moving: ");scanf("%d",&k);fun(arra,k);printf("\nNow array is:\n");for(i=0; i<RW; i++){for(j=0;j<CL;j++)printf("%6d", arra[i][j]);printf("\n");}getch();}#include <stdio.h> #include <math.h> double fun(int n) { /**//**/}void main(){int n;printf("Input n(n>=0): ");scanf("%d",&n);printf("pi=%lf\n ",fun(n));getch();}#include <stdio.h> #include <math.h> double fun(float x) { /**/ /**/}void main(){ float x;double y;printf("Please input a number: ");scanf("%f",&x);printf("f(%.2f)=%.2f\n",x,fun(x));getch();}#include <math.h> #include <stdio.h> double fun(double x) { /**/ /**/}void main(){double x;printf("Pleae input x:");scanf("%lf",&x);printf("\nfun(%6.3lf) = %6.3lf\n",x,fun(x));getch();}。
最新福建省计算机等级考试二级C语言考试题库

改错题#include <stdio.h>#include <string.h>void main(){char s1[100], s2[100];int i,s_len;printf("Please input string: \n");gets(s1);s_len = /**/ s1 /**/;for(i=0; i<s_len; i++){if(s1[i] >= '0' && s1[i] <= '7')s2[i] = s1[i] + 2;else if(s1[i] == '8'/**/ && /**/s1[i]=='9') s2[i] = s1[i]-8;elses2[i] = s1[i];}/**/ s2[i+1] /**/ = '\0';puts(s2);getch();}#include <stdio.h>#include <math.h>int prime( int x ){int i, mark=1 ;double k;/**/ i=1 /**/;k=(int)sqrt((double)x);while (i<=k){ if(x%i==0){/**/ i=k+1; /**/break;} i++;}return (mark);}void main(){int a;printf("Input a number: ");scanf("%d",&a);if(/**/ !prime(a) /**/)printf("%d is a prime number.\n", a); elseprintf("It's not.\n");getch();}#include <stdio.h>float fun(float a){ return (a*a+2*a+1)/(a-1);}void main(){float x,y,z;float result;printf("\nPlease input x,y,z: ");scanf(/**/ "%d%d%d" /**/,&x,&y,&z); if(x==1 || y==1 || z==1){ printf("Divide 0,error!");getch();return ;}result=/**/ fun(x,y,z) /**/;printf("\nResult=%.2f\n",result); getch();}#include <stdio.h>void chg(char s[]){int i;/**/ i=1 /**/;while(s[i]!='\0'){if ((s[i]>='A' && s[i]<='Z') && /**/ i%2 /**/) /**/ s[i]=s[i]-32; /**/i++;}}void main(){char str_s[100];printf("Enter string: ");gets(str_s);chg(str_s);printf("\nNow string is:");puts(str_s);getch();}#include <stdio.h>int fun(/**/ char p /**/){int x;/**/ x=1; /**/while(*p){x=x*8+*p-'0';p++;}return(/**/ *p /**/);}void main(){char str_s[6];printf("Enter string: ");gets(str_s);printf("\nDecimal is: %d",fun(str_s) ); getch();}#include <stdio.h>void main(){char str[100];char *p;p=str;scanf("%s",str);while ( /**/*p=='\0' /**/)p++;printf(/**/"The length is: %s "/**/,p-str);getch();}#include <stdio.h>void main(){ int i,gw,sw,sum=0;for(i=1;i<100;i++){sw=i/10;gw= /**/ i-sw /**/;if((gw==3 || gw==5)||(sw==3 || sw==5)) /**/ sum=i /**/;}printf("\nThe sum is:%d",sum);getch();}#include <stdio.h>#include <math.h>void fun(/**/ float a, b, c /**/){double s,area;if(a+b>c && a+c>b && b+c>a){/**/ s=a+b+c/2; /**/area=/**/ sqt(s*(s-a)*(s-b)*(s-c)) /**/ ;printf("area=%7.2f\n",area);}elseprintf("Not a triangle.\n");}void main(){float a,b,c;printf("Input a,b,c:");scanf("%f,%f,%f",&a,&b,&c);fun(a,b,c);getch();}#include <stdio.h>void main(){int i,num[100],count;/**/ count=1 /**/;for(i=1000; i<=2000; i++)if(/**/ (i-2)%4 = 0 && (i-3)%7=0 /**/){num[count]=i;count++;}printf("Total number is:%d\n", count ); for(i=0; /**/i<=count /**/;i++)printf("%d\n", num[i]);getch();}#include <stdio.h>void swap(int *p, /**/ *q /**/){int temp;/**/ *temp /**/= *p;/**/ *q = *p; /**/*q = temp;}void main(){int a,b;printf("Input 2 numbers:\n");scanf("%d%d",&a,&b);printf("\nOriginal: a=%d b=%d\n",a,b); swap(&a,&b);printf("Now: a=%d b=%d\n",a,b); getch();}填空题/**/ /**/<stdio.h> void main(){char str[100];int /**/ /**/;printf("Input string :"); gets(str);for(i=j=0; str[i]!='\0'; i++) {if(str[i]!='b'){str[j]=str[i];/**/ /**/;}}str[j]='\0';printf("Now string is:"); puts(str);getch();}#include <stdio.h>void main(){struct student{char name[10];float score;};struct student stu[5]={"Mary",76.1,"John",87.3,"Tom",81,"susa",87.8,"wilu",79}; int i=0,k=0;/**/ /**/ ;for(i=0;i<5;i++)if(stu[i].score>max){ max=/**/ /**/ ;/**/ /**/;}printf("\nname:%s,score:%.2f", stu[k].name,stu[k].score );getch();}#include <stdio.h>#include <math.h>void main(){ int i,j ;int a[5][5],sum;/**/ /**/;printf("Please input 25 numbers:\n"); for(i=0; i<5;i++)for(j=0;j<5;j++){ scanf("%d",&a[i][j]);if(/**/ /**/)sum+=a[i][j];}printf("%.5f\n",/**/ /**/); getch();}#include <stdio.h>void main(){ int i,j,k;int num=0;printf(" No. 1 yuan 2 yuan 5 yuan\n"); for(k=0;k<=2;k++)for(j=0;j<=5;j++)for(i=0;/**/ /**/;i++)if(/**/ /**/){ num++;printf("%9d%9d%9d%9d\n",num,i,j,k);}getch();}#include <stdio.h>/**/ /**/ N 10int find(int a[],int x){int i;for(/**/ /**/;i<N;i++){if(a[i]==x)return(i);}return (/**/ /**/);}void main(){int a[N]={21,56,-9,0,3,17,18,5,-23,11}; int f,f_at;printf("Input a number to be searched:"); scanf("%d",&f);f_at=find(a,f);if(f_at>=0)printf("%d is found,it's at %d\n",f,f_at); elseprintf("Not exist.\n");getch();}#include <stdio.h>void main(){ int m,n,k;for ( m = 1; m < 10 ; m++)for ( n = 1 ;/**/ /**/; n++){ k =/**/ /**/;if (k == 99)printf ( "M = %d N = %d\n", m, n );}getch();}#include <stdio.h>#define N 10void main(){int a[N]={21,56,-9,0,3,17,18,5,-23,11}; int i,j,/**/ /**/;for(i=N-1;i>=1;i--){for(j=0;j<=/**/ /**/ ;j++){if(/**/ /**/){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}}}printf("Sorted numbers:\n");for(i=0;i<N;i++)printf("%4d ",a[i]);printf("\n");getch();}#include <stdio.h>void main(){int x,na,nb,nc;na=nb=/**/ /**/;printf("Please input integer number, end with 0:\n"); scanf("%d",&x);while( x ){if(x<0)/**/ /**/;else++nb;if( abs(x%/**/ /**/)==3 )++nc;printf("Please input integer number, end with 0:\n");scanf("%d",&x);}printf("na=%d nb=%d nc=%d\n",na,nb,nc); getch();}#include <stdio.h>void main(){ enum body{zhang,wang,zhao,li};/**/ /**/ body day[12], j;int i;j=zhang;for(i=0;i<12;i++){day[i]=j;j++;if(j>li)j=/**/ /**/;}printf("List :\n");for(i=1;i<=12;i++){switch(day[i-1]){case zhang:printf("Day %2d is %s \n",i,"zhang");break;case wang:printf("Day %2d is %s \n",i,"wang");break;case /**/ /**/:printf("Day %2d is %s \n",i,"zhao");break;case li:printf("Day %2d is %s \n",i,"li");}}getch();}#include <stdio.h>void main(){int i,s[9];float aver;printf("Please input sampler:\n");for(i=0;i<9;i++)scanf("%d",&s[i]);aver=((float)/**/ /**/)/2; for(i=0;i<9;i++)if(s[i]</**/ /**/)printf("%d\n",s[i]);getch();}编程题#include <math.h>#include <stdio.h>double fun(double x){ /**//**/}void main(){double x;printf("Pleae input x:");scanf("%lf",&x);printf("\nfun(%6.3lf) = %6.3lf\n",x,fun(x)); getch();}#include <stdio.h>#include <string.h>float fun(float f, char s[]){ /**//**/}void main(){ float x,y;char str[16];printf("Input the fahrenheit temperature: "); scanf("%f",&x);y=fun(x,str);printf("the celsius temperature: %f, %s\n",y,str); getch();}#include <math.h>#include <stdio.h>double fun(double x){ /**//**/}void main(){double x;printf("Pleae input x:");scanf("%lf",&x);printf("\nfun(%6.3lf) = %6.3lf\n",x,fun(x)); getch();}#include <stdio.h>int fun(long a[]){ /**//**/}void main(){int i,n;long a[20];n=fun(a);for(i=0;i<n;i++)printf("%ld ",a[i]); printf("\n");printf("n=%d\n",n); getch();}#include <stdio.h>#include <math.h>double fun(float x){ /**//**/}void main(){ float x;double y;printf("Please input a number: "); scanf("%f",&x);printf("f(%.2f)=%.2f\n",x,fun(x)); getch();}#include <stdio.h>long fun(int n){ /**//**/}void main(){int n;printf("Input n(n>=1): ");scanf("%d",&n);printf("fun(%d) =%ld \n ",n,fun(n)); getch();}#include <stdio.h>#define RW 3#define CL 5void fun(int a[][CL],int n){ /**//**/}void main(){ int arra[RW][CL] = {{1,2,3,4,5},{11,12,13,14,15},{21,22,23,24,25}}; int i,j,k;printf("Original array is:\n");for(i=0; i<RW; i++){for(j=0;j<CL;j++)printf("%6d", arra[i][j]);printf("\n");}printf("\nInput sites of moving: ");scanf("%d",&k);fun(arra,k);printf("\nNow array is:\n");for(i=0; i<RW; i++){for(j=0;j<CL;j++)printf("%6d", arra[i][j]);printf("\n");}getch();}#include <stdio.h>#include <math.h>double fun(int n){ /**//**/}void main(){int n;printf("Input n(n>=0): "); scanf("%d",&n);printf("pi=%lf\n ",fun(n)); getch();}#include <stdio.h>#include <math.h>double fun(float x){ /**//**/}void main(){ float x;double y;printf("Please input a number: "); scanf("%f",&x);printf("f(%.2f)=%.2f\n",x,fun(x)); getch();}#include <math.h>#include <stdio.h>double fun(double x){ /**//**/}void main(){double x;printf("Pleae input x:");scanf("%lf",&x);printf("\nfun(%6.3lf) = %6.3lf\n",x,fun(x)); getch();}。
福建省计算机等级考试二级选择题(附答案)

一、单项选择题(1). 下面程序运行后,文件d_f.dat 的内容是(1 )。
main(){FILE*fp;inti=10,j=20;fp=fopen("d_f.dat","w");fprintf(fp,"%d",i);fclose(fp);fp=fopen("d_f.dat","a");fprintf("%d",j);fclose(fp);}①1020 ②20 ③2010④10(2). 若有定义:enumday{sun,mon,tue,wed,thu,fri,sat}; ,则枚举常量sun、mon的值分别为(4 )。
①70 ②12 ③71 ④01(3). 下列程序段运行后,表达式(2)的值为3。
structpoint{intx;inty;}*p;structpointa[3]={1,2,3,4,5,6};p=a;①p[3].x ②p[1].x ③*(p+2) ④p[2].x(4). 以下程序段的运行结果是(3)。
intx[]={2,3,4,5,6,7},*p=x;inti,s=0;for(i=1;i<5;i++)s+=p[i++];printf("%d",s);①20②14③8④6(5).C 语言的函数体由( 1 )括起来。
①{} ②[]③<> ④()(6). 若有定义:intx,y,z; 语句x=(y=z=3,++y,z+=y); 运行后,x的值为(2 )。
①7②6③8④3(7). 若有定义:intx;charc='A'; 则正确的赋值表达式是(4 )。
(说明:'A'的ASCII码的十进制值为65,'a'的ASCII码的十进制值为97)①x='ABC'②x=c+'ABC' ③x=c+'CBA'④x=c+32(8). 下面叙述错误的是(3)。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include <math.h> #include <stdio.h> #include <conio.h> double fun(double x) { /**/ double y,a,b; a=3*sin(x)+log(x) ; b=fabs(cos(x)-2*x) ; y=a/b ; return(y) ; /**/ }
#include <stdio.h> #include <conio.h> #define COL 5 void fun(int a[],int n) { /**/ int i,j,temp; for(i=0; i<n; i++) {temp=a[COL-1] ;
for(j= COL-1; j>0; j--) a[j]=a[j-1] ; a[0]=temp ; }
编程题
#include <math.h> #include <stdio.h> #include <conio.h> double fun(double x) { /**/ double y,a,b; a=cos(3*x)+x*x-1 ; b=fabs(log(x)-2*tan(x)+1) ; y=a/b ; return(y) ; /**/ }
#include <stdio.h> #include <conio.h> long fun(int a[],int x,int d,int n) { /**/ int i,a[0]=x;long s=x; for (i=1;i<n;i++) {a[i]=a[i-1]+d;s+=a[i];} return(s);
/**/ }
void main() { int a[N] = {40,23,33,8,32,63,2,9,16,-3,3,0,13}; int b[N]={0}; int i; float aver; printf("Array a:\n"); for(i=0;i<N;i++)
printf("%d ",a[i]); printf("\n"); fun(a,b,&aver); printf("Array b:\n"); i=0; whilb[i++]); printf("\n"); printf("Aver is :%.3f",aver); getch(); }
#include <stdio.h> #include <conio.h> #define N 13 void fun(int a[],int b[],float *f)
{ /**/ int I,j=0; float av=0; for(i=0;i<N;i++) {if (i%2!=0)&&(a[i]%10==3) b[i]=a[i]; if(i%2==0) {av+=a[i];j++;} } *f=av/j;
#include <stdio.h> #include <conio.h> #define N 15 int count(int *p,int *q) { /**/ int i,j=0; for (i=0;i<N;i++) {if( *p> *q) j++;
p++;q++;} return j;
/**/ }
#include <stdio.h> #include <math.h> #include <conio.h> double fun(float x)
{ /**/ double y; if (x>2) y=fabs(1.23*x-9) ; else if (x=2) y=exp(x)+pow(x,3) ;
else if (x<2) y=cos(x) ; return(y) ;
/**/ }
void main() { float x; double y; printf("Please input a number: "); scanf("%f",&x); printf("f(%.2f)=%.2f\n",x,fun(x)); getch(); }
void main() { int a[N] = {40,23,33,8,32,63,2,9,16,-3,3,0,13,14,15}; int b[N] = {3,0,13,14,40,63,15,23,33,8,32,2,9,16,-3}; int n; n=count(a,b); printf("n is :%d\n",n); getch(); }
#include <stdio.h> #include <conio.h> #define N 6 void fun(int a[N][N]) { /**/ int i,j; for(i=0;i<N;i++)
for(j=0;j<N-1;j++) a[i][j]=(a[i][j]+a[i][j+1])/2;
#include <stdio.h> #include <math.h> #include <conio.h> double fun(float x) { /**/
double y; if (x<1000) y=x ; else if (x>=1000)&&(x<2000) y=x-0.3*(x-1000) ;
} fun(arra); printf("Now arra is:\n"); for(i=0;i<N;i++) {for(j=0;j<N;j++)
printf("%5d",arra[i][j]); printf("\n"); } getch(); }
/**/ }
void main() { int arra[COL] = {6,7,8,9,0}; int i,j,n; printf("The array a is:\n"); for(i=0; i<COL; i++)
printf("%5d", arra[i]); printf("\n"); printf("Sites of moving(n>0): "); scanf("%d",&n); fun(arra,n); printf("Now The array a is:\n"); for(i=0; i<COL; i++) printf("%5d", arra[i]); printf("\n"); getch(); }
else if (x>=5) y=log(x) ; return(y) ;
/**/ }
void main() { float x; double y; printf("Please input a number: "); scanf("%f",&x); printf("f(%.2f)=%.2f\n",x,fun(x)); getch(); }
/**/ }
void main() { int i,j; int arra[N][N] ={{4,2,3,8,5,7},
{2,9,6,3,3,0}, {3,4,5,7,2,9}, {3,0,3,4,4,6}, {5,2,3,8,6,7}, {2,9,6,3,5,7}}; printf("arra is:\n"); for(i=0;i<N;i++) {for(j=0;j<N;j++) printf("%5d",arra[i][j]); printf("\n");
else if (x>=2000)&&(x<3000) y=x-0.5*(x-2000) ; else (x>=3000) y=x-0.8*(x-3000) ;
return(y) ;
/**/ }
void main() { float x; double y; printf("Please input a number: "); scanf("%f",&x); printf("f(%.2f)=%.2f\n",x,fun(x)); getch(); }
void main() { printf("fun(2.53) = %6.3lf\n", fun(2.53)); getch(); }
#include <stdio.h>
#include <math.h> #include <conio.h> double fun(float x) { /**/
double y; if (x<0) y=x*x+1 ; else if (x>=0)&&(x<5) y=sqrt(3*x+1);