期末复习卷《C语言程序设计》(上海科学普及出版社)(二)

2026-06-14
| 2份
| 11页
| 7人阅读
| 0人下载

资源信息

学段 中职
学科 职教专业课
课程 C语言程序设计
教材版本 -
年级 -
章节 -
类型 题集-专项训练
知识点 数据类型和简单程序设计,分支结构,循环结构,数组,函数
使用场景 同步教学-期末
学年 2026-2027
地区(省份) 湖北省
地区(市) -
地区(区县) -
文件格式 ZIP
文件大小 193 KB
发布时间 2026-06-14
更新时间 2026-06-14
作者 源栈
品牌系列 学易金卷·期末模拟卷
审核时间 2026-06-14
下载链接 https://m.zxxk.com/soft/58340290.html
价格 3.00储值(1储值=1元)
来源 学科网

内容正文:

《C语言程序设计》 期末复习卷(二) 时间:90分钟 总分:100分 班级 姓名 学号 成绩 一.程序设计题(本大题共10小题,每小题10分,共100分) 1.输入两个正整数m和n,求最大公约数和最小公倍数 #include<stdio.h> void main(){ int m,n,t,r,gcd,lcm; /*******space*******/ scanf("%d%d",&m,&n); int a=m, b=n; while(b != 0){ r = a % b; a = b; b = r; } gcd = a; lcm = m * n / gcd; /*******space*******/ } 2.输入一串字符串,统计该字符串中字母、数字、空格和其它字符的个数 #include<stdio.h> #include<string.h> void main(){ char str[200]; int letters=0,digits=0,spaces=0,others=0,i; /*******space*******/ gets(str); for(i=0; str[i]; i++){ if((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z')) letters++; else if(str[i]>='0' && str[i]<='9') digits++; else if(str[i]==' ') spaces++; else others++; } /*******space*******/ } 3.输入一个整数,判断该数是否是回文数 #include<stdio.h> void main(){ int num,reversed=0,original,remainder; /*******space*******/ scanf("%d", &num); original = num; while(num > 0){ remainder = num % 10; reversed = reversed * 10 + remainder; num /= 10; } /*******space*******/ } 4.输入一个整数n,利用递归函数求n的阶乘 #include<stdio.h> long factorial(int n) { /*******space*******/ if(n == 0 || n == 1) return 1; else return n * factorial(n - 1); /*******space*******/ } void main() { int n; /*******space*******/ scanf("%d", &n); printf("%d! = %ld ", n, factorial(n)); /*******space*******/ } 5.输入两个字符串,将这两个字符串进行拼接,要求不使用strcat函数 #include<stdio.h> void main(){ char s1[100],s2[50]; int i,j; /*******space*******/ gets(s1); gets(s2); i = 0; while(s1[i] != '\0'){ i++; } j = 0; while(s2[j] != '\0'){ s1[i] = s2[j]; i++; j++; } s1[i] = '\0'; /*******space*******/ } 6.编写程序,输入10个整数,求出其中的最大值和最小值及它们的下标 #include<stdio.h> void main(){ int a[10],i,max,min,imax,imin; /*******space*******/ for(i = 0; i < 10; i++){ scanf("%d", &a[i]); } max = min = a[0]; imax = imin = 0; for(i = 1; i < 10; i++){ if(a[i] > max){ max = a[i]; imax = i; } if(a[i] < min){ min = a[i]; imin = i; } } /*******space*******/ } 7.函数fun的功能是:统计一个整数n(n>0)中包含的偶数数字的个数。 例如:n = 123456,其中偶数数字有2、4、6,共3个,函数返回3。 #include<stdio.h> int fun(int n){ int count = 0; /*******space*******/ if(n == 0){ if(0 % 2 == 0) return 1; } while(n > 0){ int digit = n % 10; if(digit % 2 == 0){ count++; } n = n / 10; } /*******space*******/ return count; } int main() { int n = 123456; printf("数字%d中包含%d个偶数数字 ", n, fun(n)); return 0; } 8.函数fun的功能是:判断一个字符串是否是“纯字母串”(只包含大小写字母,不含数字、空格、标点等其他字符)。如果是,返回1;否则返回0 #include<stdio.h> #include<ctype.h> int fun(char s[]){ int i = 0; /*******space*******/ while(s[i] != '\0'){ if(!((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))){ return 0; } i++; } /*******space*******/ return 1; } int main(){ char s1[] = "HelloWorld"; char s2[] = "Hello123"; printf("%s : %d ", s1, fun(s1)); printf("%s : %d ", s2, fun(s2)); return 0; } 9.函数fun的功能是:将字符串s中的所有大写字母转换为小写字母,其他字符 不变。转换后的结果仍存放在原字符串中。 #include<stdio.h> void fun(char s[]){ int i = 0; /*******space*******/ while(s[i] != '\0'){ if(s[i] >= 'A' && s[i] <= 'Z'){ s[i] = s[i] + 32; } i++; } /*******space*******/ } int main(){ char s[] = "Hello World! C Programming."; fun(s); printf("%s ", s); return 0; } 10.函数fun的功能是:实现字符串的循环右移k位。例如,字符串"abcdef",k=2, 循环右移2位后变为"efabcd"。要求在原字符串上直接修改,不借助额外数组。 #include<stdio.h> #include<string.h> void reverse(char s[], int start, int end){ char temp; while(start < end){ temp = s[start]; s[start] = s[end]; s[end] = temp; start++; end--; } } void fun(char s[], int k){ int len = strlen(s); k = k % len; /*******space*******/ reverse(s, 0, len - 1); reverse(s, 0, k - 1); reverse(s, k, len - 1); /*******space*******/ } int main(){ char s[] = "abcdefgh"; int k = 3; printf("原字符串:%s ", s); fun(s, k); printf("循环右移%d位后:%s ", k, s); return 0; } 原创精品资源学科网独家享有版权,侵权必究! 学科网(北京)股份有限公司 学科网(北京)股份有限公司 学科网(北京)股份有限公司 学科网(北京)股份有限公司 $ 《C语言程序设计》 期末复习卷(二) 时间:90分钟 总分:100分 班级 姓名 学号 成绩 一.程序设计题(本大题共10小题,每小题10分,共100分) 1.输入两个正整数m和n,求最大公约数和最小公倍数 #include<stdio.h> void main(){ int m,n,t,r,gcd,lcm; /*******space*******/ /*******space*******/ } 2.输入一串字符串,统计该字符串中字母、数字、空格和其它字符的个数 #include<stdio.h> #include<string.h> void main(){ char str[200]; int letters=0,digits=0,spaces=0,others=0,i; /*******space*******/ /*******space*******/ } 3.输入一个整数,判断该数是否是回文数 #include<stdio.h> void main(){ int num,reversed=0,original,remainder; /*******space*******/ /*******space*******/ } 4.输入一个整数n,利用递归函数求n的阶乘 #include<stdio.h> long factorial(int n) { /*******space*******/ /*******space*******/ } void main() { int n; /*******space*******/ /*******space*******/ } 5.输入两个字符串,将这两个字符串进行拼接,要求不使用strcat函数 #include<stdio.h> void main(){ char s1[100],s2[50]; int i,j; /*******space*******/ /*******space*******/ } 6.编写程序,输入10个整数,求出其中的最大值和最小值及它们的下标 #include<stdio.h> void main(){ int a[10],i,max,min,imax,imin; /*******space*******/ /*******space*******/ } 7.函数fun的功能是:统计一个整数n(n>0)中包含的偶数数字的个数。 例如:n = 123456,其中偶数数字有2、4、6,共3个,函数返回3。 #include<stdio.h> int fun(int n){ int count = 0; /*******space*******/ /*******space*******/ return count; } int main() { int n = 123456; printf("数字%d中包含%d个偶数数字 ", n, fun(n)); return 0; } 8.函数fun的功能是:判断一个字符串是否是“纯字母串”(只包含大小写字母,不含数字、空格、标点等其他字符)。如果是,返回1;否则返回0 #include<stdio.h> #include<ctype.h> int fun(char s[]){ int i = 0; /*******space*******/ /*******space*******/ return 1; } int main(){ char s1[] = "HelloWorld"; char s2[] = "Hello123"; printf("%s : %d ", s1, fun(s1)); printf("%s : %d ", s2, fun(s2)); return 0; } 9.函数fun的功能是:将字符串s中的所有大写字母转换为小写字母,其他字符 不变。转换后的结果仍存放在原字符串中。 #include<stdio.h> void fun(char s[]){ int i = 0; /*******space*******/ /*******space*******/ } int main(){ char s[] = "Hello World! C Programming."; fun(s); printf("%s ", s); return 0; } 10.函数fun的功能是:实现字符串的循环右移k位。例如,字符串"abcdef",k=2, 循环右移2位后变为"efabcd"。要求在原字符串上直接修改,不借助额外数组。 #include<stdio.h> #include<string.h> void reverse(char s[], int start, int end){ char temp; while(start < end){ temp = s[start]; s[start] = s[end]; s[end] = temp; start++; end--; } } void fun(char s[], int k){ int len = strlen(s); k = k % len; /*******space*******/ /*******space*******/ } int main(){ char s[] = "abcdefgh"; int k = 3; printf("原字符串:%s ", s); fun(s, k); printf("循环右移%d位后:%s ", k, s); return 0; } 原创精品资源学科网独家享有版权,侵权必究! 学科网(北京)股份有限公司 学科网(北京)股份有限公司 学科网(北京)股份有限公司 学科网(北京)股份有限公司 $

资源预览图

期末复习卷《C语言程序设计》(上海科学普及出版社)(二)
1
期末复习卷《C语言程序设计》(上海科学普及出版社)(二)
2
所属专辑
由于学科网是一个信息分享及获取的平台,不确保部分用户上传资料的 来源及知识产权归属。如您发现相关资料侵犯您的合法权益,请联系学科网,我们核实后将及时进行处理。