高级语言程序设计模拟试题2015.doc

上传人:h**** 文档编号:168599 上传时间:2018-07-13 格式:DOC 页数:18 大小:85KB
下载 相关 举报
高级语言程序设计模拟试题2015.doc_第1页
第1页 / 共18页
高级语言程序设计模拟试题2015.doc_第2页
第2页 / 共18页
高级语言程序设计模拟试题2015.doc_第3页
第3页 / 共18页
高级语言程序设计模拟试题2015.doc_第4页
第4页 / 共18页
高级语言程序设计模拟试题2015.doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

1、 第 1 页 共 10 页 1. 输入一个字符串,内有数字和非数字字符,例如: “A123x456 17960? 302tab5876”,将其中连续的数字作为一个整数,依次存在到一数组 a 中。例如, 123 放在 a0, 456 放在 a1统计共有多少个整数,并输出这些数。 (完成 fun 函数 ) 如:输入 A123x456 17960? 302tab5876,输出为共有 5个整数,分别为 123,456,17960,302,5876。 #include void fun(char *p,int t,int *x) int main() char st80; int a80,n,i; ge

2、ts(st); fun(st,a, printf(“共有 %d个整数 :n“,n); for(i=0;i #include void encrypt(char *s) int main() char t180,ch; gets(t1); printf(“nthe original data is :%s“,t1); encrypt(t1); printf(“nthe resulted data is :%s“,t1); printf(“n“); 第 2 页 共 10 页 return 0; 3. 用选择法实现对 10 个整数按从小到大的顺序排序输出(要求 完成 sort 函数 )。 #incl

3、ude int main() int a10,i,j; void sort(int *); for(i=0;i int main() char a100,b20; void copy_string(char *,char *); gets(b); printf(“n the original data is :%s“,b); copy_string(a,b); printf(“n the result data is :%sn“,a); return 0; void copy_string(char *p,char *q) 第 3 页 共 10 页 5. 完成 fun 函数: 统计 tt 所指

4、字符串中 a到 z共 26 个 小写字母各自出现的次数,并依此放在pp 所指数组中。 例如:当输入 abcdefgabcdeabc 后,程序的输出结果应该为: 3 3 3 2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 #include void fun(char *tt,int pp) void main() char aa1000; int bb26,k; printf(“nplease enter a char string:“); scanf(“%s“,aa); fun(aa,bb); for(k=0;k int main() int a10,i,j; void sor

5、t(int *); for(i=0;i #include #define MAX 100 void fun(char *ss) void main() char tt51; printf(“input a string within 50 characters:n“); gets(tt); printf(“nnafter changing,the stringn “%s“,tt); fun(tt); printf(“nbecomesn “%s“,tt); printf(“n“); 8. 有一篇文章,共有 4 行,每行有 10 个字符。要求分别统计出其中英文大写字符、小写字母、数字、空格以及其他

6、字符的个数。( 完成 count 函数 ) #include int main() void count(char (*p)10,int ); char str410; int wzxmt5=0,0,0,0,0;/分别统计大写、小写、数字、空格、其他字符个数 printf(“input 4 string:n“); for(int i=0;i #include #define N 5 struct Student char name10; int socre; studN; void save() void read() int main() printf(“please enter data

7、of student:n“); for(int i=0;i #include #include void write(char (*st)20,FILE *fp1) 第 6 页 共 10 页 void output(FILE *fp2) char buf30; if (fp2=fopen(“d:file.txt“,“r“)=NULL) printf(“cant open filen“); exit(0); while (fgets(buf,20,fp2) printf(“%s“,buf); fclose(fp2); int main() FILE *fp; char a320,t10; int

8、 i,j,k; printf(“Enter three strings:n“); for(i=0;i #include void creatfile() FILE *fp; char st20; printf(“输入第一个字符串: “); gets(st); if (fp=fopen(“d:file1.txt“,“w“)=NULL) printf(“can not open file“); exit(0); 第 7 页 共 10 页 fputs(st,fp); fclose(fp); printf(“n 输入第二个字符串: “); gets(st); if (fp=fopen(“d:file2

9、.txt“,“w“)=NULL) printf(“can not open file“); exit(0); fputs(st,fp); fclose(fp); void hebing(char st,int n) void output(FILE *fp1,int n) char ch; if (fp1=fopen(“d:file3.txt“,“r“)=NULL) printf(“can not open file“); exit(0); printf(“n“); while (ch=fgetc(fp1)!=EOF) putchar(ch); printf(“n“); fclose(fp1)

10、; int main() FILE *fp; int i,j,n,i1; char c100,t,ch; creatfile(); if(fp=fopen(“d:file1.txt“,“r“)=NULL) printf(“ncan not open filen“); exit(0); printf(“file1:n“); for(i=0;(ch=fgetc(fp)!=EOF;i+) ci=ch; 第 8 页 共 10 页 putchar(ci); fclose(fp); i1=i; if(fp=fopen(“d:file2.txt“,“r“)=NULL) printf(“ncan not op

11、en filen“); exit(0); printf(“nfile2:n“); for(i=i1;(ch=fgetc(fp)!=EOF;i+) ci=ch; putchar(ci); fclose(fp); hebing(c,i); printf(“nfile3:n“); output(fp,i); return 0; 12. 写一个函数,完成将 任意 一个数组中的值按逆序重新存放。 (数组长度不超过 6 位) 要求:数组内容的内容输入和重新存放后的输出都要在主函数中实现。 如 :输入内容为 5个整数,分别为 8 6 5 4 1,重新存放后输出 为 : the result is 1,4,5

12、,6,8。 13. 写一个判断素数的函数,在主函数输入一个整数,是素数时输出 yes,否则输出 no,结果要求在主函数中输出。 14. 用递归调用的方法求 n!。 如:输入为 5,输出为 5! =120。 15. 编写一个函数,实现在一个升序排列的整型数组 1,3,5,7,14,23,45,87,155,231; 中插入 任意一个整数的功能 ,保持整型数组仍然升序排列 , 并在 main 函数中调用此函数,输入数据和最后输出都在主函数中实现。 #include int a11=1,3,5,7,14,23,45,87,155,231; int main() int c,i; void fun(i

13、nt a,int c); printf(“input an integer:“); 第 9 页 共 10 页 scanf(“%d“, fun(a,c); for(i=0;i int main() void ave(int a10); int a10,i; for(i=0;i #include int fun(char a,char b) int main() char a100,b100,i; gets(a); gets(b); i=fun(a,b); switch(i) case 0:printf(“第一个字符串大 n“);break; case 1:printf(“第二个字符串大 n“);break;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育教学资料库 > 复习参考

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。