




已阅读5页,还剩111页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第1套题一、程序填空题#include #include #define N 5typedef struct int num; char name10; char tel10;STYPE;void check();/*found*/int fun(STYPE*std)/*found*/ FILE *fp; int i; if(fp=fopen(myfile5.dat,wb)=NULL) return(0); printf(nOutput data to file !n); for(i=0; iN; i+)/*found*/ fwrite(&stdi, sizeof(STYPE), 1, fp); fclose(fp); return (1);二、程序改错题#include #include void fun (char *s, char *t) int i, sl; sl = strlen(s);/*found*/ for( i=0; i=sl; i +) ti = si; for (i=0; isl; i+)tsl+i = ssl-i-1;/*found*/ tsl+sl = 0;main() char s100, t100; printf(nPlease enter string s:); scanf(%s, s); fun(s, t); printf(The result is: %sn, t);第2套题一、程序填空题#include #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( open fail!n); exit(0); ReadText(fp); fclose(fp);/*found*/void WriteText(FILE *fw) char str81; printf(nEnter string with -1 to end :n); gets(str); while(strcmp(str,-1)!=0) /*found*/ fputs(str,fw); fputs(n,fw); gets(str); void ReadText(FILE *fr) char str81; printf(nRead file and output to screen :n); fgets(str,81,fr); while( !feof(fr) ) /*found*/ printf(%s,str); 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*10; main() long s, t; printf(nPlease enter s:); scanf(%ld, &s); fun(s, &t); printf(The result is: %ldn, t);第3套题一、程序填空题#include #include int fun(char *fname ) FILE *fp; int i,n; float x; if(fp=fopen(fname, w)=NULL) return 0; for(i=1;i=10;i+)/*found*/ fprintf(fp,%d %fn,i,sqrt(double)i); printf(nSucceed!!n);/*found*/ Fclose(fp); printf(nThe data in file :n);/*found*/ if(fp=fopen(myfile3.tex,r)=NULL) return 0; fscanf(fp,%d%f,&n,&x); while(!feof(fp) printf(%d %fn,n,x); fscanf(fp,%d%f,&n,&x); fclose(fp); return 1;main() char fname=myfile3.txt; fun(fname);二、程序改错题#include #include void fun ( int n, int *a ) int i, j, p, t; for ( j = 0; jn-1 ; j+ ) p = j;/*found*/ for ( i=j+1; iai )/*found*/ p=i; if ( p!=j ) t = aj; aj = ap; ap = t; void putarr( int n, int *z ) int i; for ( i = 1; i = n; i+, z+ ) printf( %4d, *z ); if ( !( i%10 ) ) printf( n ); printf(n);main() int aa20=9,3,0,4,1,2,5,6,8,10,7, n=11; printf( nnBefore sorting %d numbers:n, n ); putarr( n, aa ); fun( n, aa ); printf( nAfter sorting %d numbers:n, n ); putarr( n, aa );第4套题一、程序填空题#include #include int fun(char *source, char *target) FILE *fs,*ft; char ch;/*found*/ if(fs=fopen(source, r )=NULL) return 0; if(ft=fopen(target, w)=NULL) return 0; printf(nThe data in file :n); ch=fgetc(fs);/*found*/ while(!feof(fs) putchar( ch );/*found*/ fputc(ch,ft); ch=fgetc(fs); fclose(fs); fclose(ft); printf(nn); return 1;二、程序改错题#include void fun (long s, long *t) int 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, &s); fun(s, &t); printf(The result is: %ldn, t);第5套题一、程序填空题#include #include #define N 8typedef 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=x; q=h; p=h-next; while(p!=NULL & xp-data) /*found*/ q=p; p=p-next; s-next=p;/*found*/ q-next=s;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); 二、程序改错题#include long fun (long num)/*found*/ long k=1; do k*=num%10 ;/*found*/ Num/=10 ; while(num) ; return (k) ;main( ) long n ; printf(nPlease enter a number:) ; scanf(%ld,&n) ; printf(n%ldn,fun(n) ;第6套题一、程序填空题#include #include #define N 8typedef struct list int data; struct list *next; SLIST;void fun( SLIST *p) SLIST *t, *s; t=p-next; s=p; while(t-next != NULL) s=t;/*found*/ t=t-next; /*found*/ printf( %d ,t-data); s-next=NULL;/*found*/ free(t);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); 二、程序改错题#include /*found*/fun (char*a) if ( *a ) fun(a+1) ;/*found*/ printf(%c, *a) ; main( ) char s10=abcd; printf(处理前字符串=%sn处理后字符串=, s); fun(s); printf(n) ;第7套题一、程序填空题#include #include #define N 8typedef struct list int data; struct list *next; SLIST;void fun( SLIST *h) SLIST *p, *q; p=h-next; if (p!=NULL) q=p-next; while(q!=NULL) if (p-data=q-data) p-next=q-next;/*found*/ free(q);/*found*/ q=p-next; else p=q;/*found*/ q=q-next; 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;二、程序改错题#include #define N 20void fun(int a, int n) int i, j, t, p; for (j = 0 ;j n-1 ;j+) /*found*/ p = j; for (i = j+1;i n; i+) if(ai ap)/*found*/ p =i; t = ap ; ap = aj ; aj = t; main() int aN=9,6,8,3,-1,i, m = 5; printf(排序前的数据:) ; for(i = 0;i m;i+) printf(%d ,ai); printf(n); fun(a,m); printf(排序后的数据:) ; for(i = 0;i m;i+) printf(%d ,ai); printf(n);第8套题一、程序填空题#include #include #define N 8typedef struct list int data; struct list *next; SLIST;SLIST *creatlist(char *);void outlist(SLIST *);int fun( SLIST *h, char ch) SLIST *p; int n=0; p=h-next;/*found*/ while(p!=NULL) n+;/*found*/ if (p-data=ch) return n; else p=p-next; return 0;main() SLIST *head; int k; char ch; char aN=m,p,g,a,w,x,r,d; head=creatlist(a); outlist(head); printf(Enter a letter:); scanf(%c,&ch);/*found*/ k=fun(head,ch); if (k=0) printf(nNot found!n); else printf(The sequence number is : %dn,k);SLIST *creatlist(char *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(-%c,p-data); p=p-next; while(p!=NULL); printf(-Endn); 二、程序改错题#include #include #include fun ( char *p) int i,t; char c80;/*found*/ for (i = 0,t = 0; pi ; i+) if(!isspace(*(p+i) ct+=pi;/*found*/ ct= 0; strcpy(p,c);main( ) char c,s80; int i=0; printf(Input a string:); c=getchar(); while(c!=#) si=c;i+;c=getchar(); si=0; fun(s); puts(s);第9套题一、程序填空题#include #include #define N 8typedef struct list int data; struct list *next; SLIST;SLIST *creatlist(int *a);void outlist(SLIST *);void fun( SLIST *h, int *n) SLIST *p;/*found*/ *n=0; p=h-next; while(p) (*n)+;/*found*/ p=p-next; main() SLIST *head; int aN=12,87,45,32,91,16,20,48, num; head=creatlist(a); outlist(head);/*found*/ fun(head, &num); printf(nnumber=%dn,num);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;二、程序改错题#include #include char * fun (char *s, char *t ) char *p , *r, *a;/*found*/ a = NULL; while ( *s ) p = s; r = t; while ( *r )/*found*/ if (* r =* p ) r+; p+; else break; if ( *r = 0 ) a = s; s+; return a ;main() char s100, t100, *p; printf(nPlease enter string S :); scanf(%s, s ); printf(nPlease enter substring t :); scanf(%s, t ); p = fun( s, t ); if ( p ) printf(nThe result is : %sn, p); else printf(nNot found !n );第10套题一、程序填空题#include #include #define N 8typedef struct list int data; struct list *next; SLIST;SLIST *creatlist(int *);void outlist(SLIST *);int fun( SLIST *h) SLIST *p; int s=0; p=h-next; while(p) /*found*/ s+= p-data;/*found*/ p=p-next; return s;main() SLIST *head; int aN=12,87,45,32,91,16,20,48; head=creatlist(a); outlist(head);/*found*/ printf(nsum=%dn, fun(head);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;二、程序改错题#include #include void fun (char *s, char *t1, char *t2 , char *w) char *p , *r, *a; strcpy( w, s ); while ( *w ) p = w; r = t1;/*found*/ while (* r ) if ( *r = *p ) r+; p+; else break; if ( *r = 0 ) a = w; r = t2; while ( *r )/*found*/ *a = *r; a+; r+; w += strlen(t2) ; else w+; 第11套题一、程序填空题#include #include #define M 5#define N 20int fun(char (*ss)N, int *n) int i, k=0, len= N;/*found*/ for(i=0; iM; i+) len=strlen(ssi); if(i=0) *n=len;/*found*/ if(len *n) *n=len; k=i; /*found*/ return(k);二、程序改错题#include #include char* fun( char tt ) int i; for( i = 0; tti; i+ )/*found*/ if( a = tti )&( tti = z ) )/*found*/ tti-= 32; return( tt );main( ) char tt81; printf( nPlease enter a string: ); gets( tt ); printf( nThe result string is:n%s, fun( tt ) );第12套题一、程序填空题#include void fun(char *s) int i, j=0, k=0; char t180, t280; for(i=0; si!=0; i+) if(si=0 & si=9) /*found*/ t2j=si; j+; else t1k+=si; t2j=0; t1k=0;/*found*/ for(i=0; ik; i+) si=t1i;/*found*/ for(i=0; ij; i+) sk+i=t2i;main() char s80=def35adh3kjsdf7; printf(nThe original string is : %sn,s); fun(s); printf(nThe result is : %sn,s);二、程序改错题#include #include #define MAXLINE 20fun ( char *pstr6) int i, j ; char *p ; for (i = 0 ; i 5 ; i+ ) /*found*/ for (j = i + 1; j 0) p = *(pstr + i) ;/*found*/ *(pstr + i) = *(pstr + j ); *(pstr + j) = p ; 第13套题一、程序填空题#include void fun(char *s) int i, j, n; for(i=0; si!=0; i+)/*found*/ if(si=0 & sii; j-)/*found*/ sj+1= sj; sj+1=*; i=i+1; main() char s80=ba3a54cd23a; printf(nThe original string is : %sn,s); fun(s); printf(nThe result is : %sn,s);二、程序改错题#include double fun ( int m ) double y = 1.0 ; int i;/*found*/ for(i = 2 ; i = m ; i+)/*found*/ y += 1.0 / (i * i) ; return( y ) ;main( ) int n = 5 ; printf( nThe result is %lfn, fun ( n ) ) ;第14套题一、程序填空题#include void fun(char *s, int *t) int i, n; n=0;/*found*/ for(i=0; si!=0; i+)/*found*/ if(si=0&si= 9) n+;/*found*/ *t=n ;main() char s80=abcdef35adgh3kjsdf7; int t; printf(nThe original string is : %sn,s); fun(s,&t); printf(nThe result is : %dn,t);二、程序改错题#include int fun(int *x,int y) int t ;/*found*/ t =* x ;* x = y ;/*found*/ return(t) ;main() int a = 3, b = 8 ; printf(%d %dn, a, b) ; b = fun(&a, b) ; printf(%d %dn, a, b) ;第15套题一、程序填空题#include void fun(char *s) int i, n, k; char c; n=0; for(i=0; si!=0; i+) n+;/*found*/ if(n%2=0) k=n-1 ; else k=n-2;/*found*/ c=sk ; for(i=k-2; i=1; i=i-2) si+2=si;/*found*/ s1=c;main() char s80=abcdefgh; printf(nThe original string is : %sn,s); fun(s); printf(nThe result is : %sn,s);二、程序改错题#include long fun (int a, int n) int j ;/*found*/ long s = 0, t =0; for ( j = 0 ; j n ; j+) t = t * 10 + a ; s = t ; for ( j = 1 ; j n ; j+) /*found*/ t = t/10 ; s = s - t ; return(s) ;main( ) int a, n ; printf( nPlease enter a and n:) ; scanf( %d%d, &a, &n ) ; printf( The value of function is: %ldn, fun ( a, n ) );第16套题一、程序填空题#include void fun(char *s, char *p) int i, j, n, x, t; n=0; for(i=0; si!=0; i+) n+; for(i=1; in-2; i=i+2) /*found*/ t=i/*found*/ for(j=i+2 ; jsj) t=j; if(t!=i) x=si; si=st; st=x; for(i=1,j=0; in; i=i+2, j+)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 宿舍说话检讨书
- 四川省宜宾市2024-2025学年七年级下学期期末考试数学试卷(含答案)
- 江苏省常州市钟楼区小学英语五年级下册期末检测卷(含答案)
- 《大数据审计基础》全套教学课件
- 安徽省阜阳市2024-2025学年八年级下学期期末教学质量检测数学试卷(含答案)
- 3D打印:从原理到创新应用知到智慧树答案
- 电商平台消费者隐私数据保护策略研究
- 餐饮行业外卖模式创新案例分析
- “四史”概论知到智慧树答案
- 水银泄露处理课件
- 绿化养护手册
- 阿里云培训课件
- 《隧道抗震韧性评价标准》标准文本附编制说明
- 初一新生家长会(共27张课件)
- 颂钵疗愈师培训
- 2024至2030年中国齿科应用技术数据监测研究报告
- 《健康管理职业导论》高职健康管理专业全套教学课件
- 贵州省2023年中考语文现代文阅读真题及答案
- (完整版)英语选修7单词表
- SLT712-2021 河湖生态环境需水计算规范
- DZ∕T 0130.6-2006 地质矿产实验室测试质量管理规范 第6部分:水样分析(正式版)
评论
0/150
提交评论