1、 PI(bj)*(bj) /*Found*/ int mianJi;double mianJi = S(2+3); printf(”mian ji=5。2fn, mianJi);4、相似题:D3.C,程序D5。c的功能是将字符串yy显示在屏幕上。#include /*Found*/ char yy100 = ”ok?n, /改为:; /*Found*/ prntf(s, yy); /改:printf return 0;5、考查点:数据类型选择,/运算符的使用功能是计算1/1 + 1/2 + + 1/N之和并显示。h#define N 10 /*Found*/ long jieguo = 0;
2、int fm; for (fm = 1; fm = N; fm+) /*Found*/ jieguo += 1 / fm;(float) 1 / fm printf(”8.6fn, jieguo);6、考查点:输入分隔格式控制,循环体的定义, D12.c的功能是从键盘读入a和b的值(输入格式限定为仅a,b),在屏幕上显示b行a。#includestdio。 int a, b; /*Found*/ scanf(”dd, &a, b); /中间加, while (b 0) /*Found*/ _ /括号dn, a); b-; /*Found*/ _ /括号 printf(”bye bye!n”);
3、7考查点:输入格式控制、变量交换,程序D1000。c的功能是从键盘输入3个浮点数a,b,c(输入时abc之间以空格相隔),首先按照输入顺序显示在屏幕上,然后按从小到大顺序把它们输出到屏幕上。#includestdio.h float a, b, c, t; printf(”please input three numbers:n”); /*Found*/ scanf(”ff”, a, b, &c); /改:f%f%f printf(before sort:a=g,b=g,c=gn”, a, b, c); if (a b) t = a; a = b; /*Found*/ b = a;t c) t
4、 = a; a = c; c = t; if (b t = b; b = c; c = t;after sort:a=g,b=g,c=gn”, a, b, c); return 0;8考查点:格式化输出、数据类型的正确使用,程序D1001。c的功能是求分数序列:2/1,3/2,5/3,8/5,13/8,21/13,.。前20项之和,要求显示的结果中小数部分有4位.includestdio。define T 20 int n; /*Found*/ long i, j, temp, sum; i = 2; j = 1; sum = 0; for (n=1; n=T; n+) sum = sum +
5、 i / j; temp = i; i = i + j; j = temp; /*Found*/2/1+3/2+5/3+8/5+13/8+。=5.2fn”, sum);4 9考查点:用算术表达式实现数据交换,程序D1002。c的功能是实现两数交换.#includestdio.h int x = 5, y = 9; x = x + y; y = x y; /*Found*/ x = y - x;x y;x=d, y=dn”, x, y);10考查点:整型常量表示、输出项表示,程序D1003。c的功能是将16进制数100转换为10进制数输出。 /*Found*/ int i = 100; /0x1
6、00 /*Found*/%dn, i);去掉11、程序D1004。c的功能是输入姓名,屏幕输出问候。 char s10; printf(”please input your name:); /*Found*/ scanf(c, s); /改s printf(”hello ); /*Found*/ puts(s10);s 12考查点:输入数据分隔,输出项表示,程序D1005.c的功能是从键盘读入两个整数并在屏幕上显示.要求:输入时限定两数之间仅以逗号隔开。#includestdio.h int a, b; /*Found*/dd”, &a, &b);中间加, /*Found*/ printf(”
7、a=d,b=%dn”, &a, & /去掉& 13、考查点:输入格式控制、if语句,程序D1006。c的功能是判断输入的数据是否与已经给出的数据j相等.#includestdio.h long int i = 79870, j = 23; /*Found*/%f”, i);%ld /*Found*/ if (j = i); printf(Equal!”); else printf(”Not equal!14、考查点:字符输入函数使用,分支条件表示,程序D1007.c的功能是使用getchar方式从键盘读入一个字符,判断该字符是否大写字符。#includestdio。 char ch; /*Fo
8、und*/ getchar(ch); / ch = getchar(); /*Found*/ if (A = ch, ch = Z) /& printf(”yes”); elseno return 0; 15、考查点:switch语句结束、case后常量表示,程序D1008。c的功能是判断用户是不是输入的整数0.includestdio.h%d, n); /*Found*/ switch (n); /去掉; /*Found*/ case0: /中间加空格 printf(Zeron”); break; default: printf(”NonZero”); break;16、考查点:switch
9、语句、case后常量表示,程序D1009.c的功能是输入一个整数,如果为1时输出100,为2时输出200,其它输出0。include int x, y;%d”, &x); switch (x) /*Found*/ case x = 1:1 y = 100; /*Found*/ case x = 2:2 y = 200; default: /*Found*/ y = 500; printf(”%dn”, y);17、考查点:switch语句case常量表示,循环条件表示,程序D1010.c的功能是输入若干字符数据(回车表示输入结束),分别统计其中A、B、C的个数。includestdio.h c
10、har c; int k1 = 0, k2 = 0, k3 = 0; /*Found*/ while (c = getchar() != n) /加括号() switch (c) /*Found*/ case A: /加 k1+; break; case B: k2+; case C: k3+; break; default : ; printf(”A=%d,B=%d,C=dn, k1, k2, k3);18、考查点:一维数组定义、数组元素引用、输入和输出,程序D1016。c的功能是从键盘输入5个整数,保存到一整型数组变量中(此数组只能保存5个数),并在屏幕上按逆序输出。 /*Found*/
11、int n=5, i, an; /改为5ninput 5 numbers: /*Found*/ for (i=1; i ai) min = ai; printf(”Max number is:%。2fnMin number is:%.2fn”, max, min);20、考查点:函数声明,静态变量使用,程序D1021。c的功能是依次输出31到35。/*Found*/int f(n); /用定义形式:int n for (i=1; i=5; printf(”dn”, f(3);int f(int n) /*Found/ int p = 1; static int p = p * n; retur
12、n p;21、考查点:静态变量使用,函数调用,程序D1023.c的功能是函数outnum输出自己是第几次被调用。void outnum(void); for (i=0; i5; /*Found*/ outnum(i); outnum()void outnum(void) /*Found*/ int i = 0;static int i = 0; i+;, i);22、考查点:函数调用、函数定义,程序D1024.c的功能是调用子函数Average()求两数的平均值,并输出到屏幕上./*Found*/int Average(x, y); /用定义形式:int x, int y int a = 12
13、; int b = 24; int ave; /*Found*/ ave = Average(int a, int b); /用使用形式:a, b printf(”Average of %d and %d is %d。n”, a, b, ave);/*Found*/int Average(x, y) /int x, int y int result; result = (x + y) / 2; return result;23、考查点:函数一般调用和静态变量,程序D1025。c的功能是输入一整数n(n0),main()函数中调用子函数Func()n次,并在屏幕上打印出每次调用该子函数的次数.v
14、oid Func(void); int i, n;ninput a data:”); scanf(”d”, n); for (i=0;n; /*Found*/ _ / Func()void Func(void) /*Found*/ _ / static int times = 0; times+;Func() was called %d time(s)。, times);难度21、考查点:用指针访问字符数组元素,程序D3。c的功能是将字符串yy在屏幕上输出. /*Found*/ char yy200 = ok?n”;*yy /*Found*/ fol (; *yy; yy+) /改为:for
15、putchar(yy);2、考查点:字符数组定义,字符串输出控制,标准字符串函数的使用,程序D6。c的功能是从键盘读入一行字符(包括空格、TAB等字符)并在屏幕上显示。 /*Found*/ char yyy。 /*Found*/ char x, y;int x = 39270; y = 41001; /*Found*/ if (x != y) /改为:=x=y /*Found*/ else;; /去掉; printf(”xyn”);4、考查点:文件路径名表示,文件打开方式选择,文件打开成功判断,程序D8。c的功能是打开文件d:te。c用于读并判断打开是否成功.include FILE fp;
16、/*Found*/ char fileName = d:te.c /*Found*/ fp = fopen(fileName, ”wr /*Found*/ if (fp is NULL) /改为: puts(File Open Error! return 1; putchar(fgetc(fp); fclose(fp);指针,内存分配、内存释放函数的使用,程序D9.c的功能是申请100个字节的内存空间,显示其首地址,然后释放申请到的内存空间.includestdio。stdlib。 /*Found*/ char pch2;pch /*Found*/ if (pch = (char )malloc(100) = NULL) /将红色部分括起来 printf(”malloc memory fail!n”)
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2