新视野二级C语言上机题库

上传人:飞*** 文档编号:39921922 上传时间:2018-05-21 格式:DOC 页数:146 大小:1.78MB
返回 下载 相关 举报
新视野二级C语言上机题库_第1页
第1页 / 共146页
新视野二级C语言上机题库_第2页
第2页 / 共146页
新视野二级C语言上机题库_第3页
第3页 / 共146页
新视野二级C语言上机题库_第4页
第4页 / 共146页
新视野二级C语言上机题库_第5页
第5页 / 共146页
点击查看更多>>
资源描述

《新视野二级C语言上机题库》由会员分享,可在线阅读,更多相关《新视野二级C语言上机题库(146页珍藏版)》请在金锄头文库上搜索。

1、第第 1 套题套题一、程序填空题#include #include #define N 5 typedef struct int num;char name10;char tel10; STYPE; void check();/*found*/ int fun(_1_ *std) /*found*/_2_ *fp; int i;if(fp=fopen(“myfile5.dat“,“wb“)=NULL)return(0);printf(“nOutput data to file !n“);for(i=0; i #include void fun (char *s, char *t) int i,

2、 sl;sl = strlen(s); /*found*/for( i=0; i void fun(int a, int b, long *c) main() int a,b; long c;void NONO ( );printf(“Input a b:“); scanf(“%d%d“, fun(a, b, printf(“The result is: %dn“, c);NONO(); void NONO ( ) /* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *rf, *wf ;int i, a,b ; long c ;rf = fopen(“K:k012

3、4010001in.dat“, “r“) ;wf = fopen(“K:k0124010001out.dat“,“w“) ;for(i = 0 ; i #include #include void WriteText(FILE *); void ReadText(FILE *); main() FILE *fp;if(fp=fopen(“myfile4.txt“,“w“)=NULL) printf(“ open fail!n“); exit(0); WriteText(fp);fclose(fp);if(fp=fopen(“myfile4.txt“,“r“)=NULL) printf(“ op

4、en fail!n“); exit(0); ReadText(fp);fclose(fp); /*found*/ void WriteText(FILE _1_) char str81;printf(“nEnter string with -1 to end :n“);gets(str);while(strcmp(str,“-1“)!=0) /*found*/fputs(_2_,fw); fputs(“n“,fw);gets(str); void ReadText(FILE *fr) char str81;printf(“nRead file and output to screen :n“)

5、;fgets(str,81,fr);while( !feof(fr) ) /*found*/printf(“%s“,_3_);fgets(str,81,fr); 二、程序改错题#include /*found*/ void fun (long s, long t) long sl=10;*t = s % 10;while ( s 0) s = s/100;*t = s%10 * sl + *t; /*found*/ sl = sl*100; main() long s, t;printf(“nPlease enter s:“); scanf(“%ld“, fun(s, printf(“The

6、result is: %ldn“, t); 三、程序编写题#include #define N 16 typedef struct char num10;int s; STREC; int fun( STREC *a, STREC *b ) main() STREC sN=“GA05“,85,“GA03“,76,“GA02“,69,“GA04“,85, “GA01“,91,“GA07“,72,“GA08“,64,“GA06“,87, “GA015“,85,“GA013“,91,“GA012“,64,“GA014“,91, “GA011“,91,“GA017“,64,“GA018“,64,“GA

7、016“,72;STREC hN;int i,n;FILE *out ;n=fun( s,h );printf(“The %d lowest score :n“,n);for(i=0;i #include int fun(char *fname ) FILE *fp; int i,n; float x;if(fp=fopen(fname, “w“)=NULL) return 0;for(i=1;i #include void fun ( int n, int *a ) int i, j, p, t;for ( j = 0; jai ) /*found*/t=i;if ( p!=j ) t =

8、aj; aj = ap; ap = t; void putarr( int n, int *z ) int i;for ( i = 1; i void fun(int a, int b, long *c) main() int a,b; long c;void NONO ( );printf(“Input a b:“);scanf(“%d%d“, fun(a, b, printf(“The result is: %ldn“, c);NONO(); void NONO ( ) /* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *rf, *wf ;int i, a,

9、b ; long c ;rf = fopen(“K:k0124010001in.dat“, “r“) ;wf = fopen(“K:k0124010001out.dat“,“w“) ;for(i = 0 ; i #include int fun(char *source, char *target) FILE *fs,*ft; char ch; /*found*/if(fs=fopen(source, _1_)=NULL)return 0;if(ft=fopen(target, “w“)=NULL)return 0;printf(“nThe data in file :n“);ch=fgetc

10、(fs); /*found*/while(!feof(_2_) putchar( ch ); /*found*/fputc(ch,_3_);ch=fgetc(fs);fclose(fs); fclose(ft);printf(“nn“);return 1; main() char sfname20 =“myfile1“,tfname20=“myfile2“;FILE *myf; int i; char c;myf=fopen(sfname,“w“);printf(“nThe original data :n“);for(i=1; ivoid fun (long s, long *t) int

11、d;long sl=1;*t = 0;while ( s 0) d = s%10; /*found*/if (d%2=0) *t=d* sl+ *t;sl *= 10; /*found*/s = 10; main() long s, t;printf(“nPlease enter s:“); scanf(“%ld“, fun(s, printf(“The result is: %ldn“, t); 三、程序编写题#include #include void fun(char *s, char t) main() char s100, t100;void NONO ( );printf(“nPl

12、ease enter string S:“); scanf(“%s“, s);fun(s, t);printf(“nThe result is: %sn“, t);NONO(); void NONO ( ) /* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */char s100, t100 ;FILE *rf, *wf ;int i ;rf = fopen(“K:k0124010001in.dat“,“r“) ;wf = fopen(“K:k0124010001out.dat“,“w“) ;for(i = 0 ; i #include #define N 8 typedef

13、 struct list int data;struct list *next; SLIST; void fun( SLIST *h, int x) SLIST *p, *q, *s;s=(SLIST *)malloc(sizeof(SLIST); /*found*/s-data=_1_;q=h;p=h-next;while(p!=NULL p=p-next;s-next=p; /*found*/q-next=_3_; SLIST *creatlist(int *a) SLIST *h,*p,*q; int i;h=p=(SLIST *)malloc(sizeof(SLIST);for(i=0; idata=ai; p-next=q; p=q;p-next=0;return h; void outlist(SLIST *h) SLIST *p;p=h-next;if (p=NULL) printf(“nThe list is NULL!n“);else printf(“nHead“);do printf(“-%d“,p-data); p=p-next; while(p!=NULL);printf(“-Endn“); main() SLIST *head; int x;int

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

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号