已阅读5页,还剩28页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2012年 9月 C语言上机押题(海贝上机资料上的套题号)P2 2.P2 3. P3 5. P4 6. P6 11. P7 13. P7 14. P8 15. P11 7. P11 9.P12 10. P15 18. P16 20. P17 22. P18 23. P20 28. P22 33. P23 2. P24 4.P28 8. P29 11. P31 15. P32 17. P37 10. P39 13. P40 14. P40 15. P42 4. P44 7. P45 9. P49 1. P51 4. P51 1. P52 1.P65 3. P66 2. P67 3. P67 1.P74 1. P78 10. P80 15. P81 16. P83 20. P83 21. P84 23. P86 2. P87 3.P88 5.P88 6. P89 7. P89 8. P90 10. P91 11. P91 12. P93 17. P94 18. P95 2. P96 3.P98 7. P98 8. P99 1. P108 4. P107 3. P110 3. P110 1. P111 2. P112 2. P114 5.P114 6. P115 7. P116 9. P116 10. P117 11. P118 2. P122 7. P123 1. P124 2.P125 3. P127 5. P128 6. P130 1. P130 2. P134 2. P134 3. P135 4. P135 5.P137 7. P138 8.以下是资料上没有的题目和做完的答案#include double fun(double x, int n) double f, t; int i;f = 1.0;/*found*/t = 1.0; /*found*/for (i=1; i#include void fun(char *s, char t)int i,n=0;for(i=0;si;i+)if(si%2=0) tn+=si;tn=0;main()char s100, t100;void NONO ();printf(“nPlease 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:n.dat“,“r“) ;wf = fopen(“K:ut.dat“,“w“) ;for(i = 0 ; i double fun( int m )double t = 1.0;int i;for( i = 2; i t+=1.0/i;/*found*/return t;main()int m;printf( “nPlease enter 1 integer number:“ );scanf( “%d“, printf( “nThe result is %lfn“, fun( m ) );#include void fun(int a, int b, long *c)int gw,sw,bw,qw;qw=b%10;bw=a%10;sw=b/10;gw=a/10;*c=qw*1000+bw+100+sw*10+gw;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,b ; long c ;rf = fopen(“K:n.dat“, “r“) ;wf = fopen(“K:ut.dat“,“w“) ;for(i = 0 ; i double fun(double e) int i, k; double s, t, x;s=0; k=1; i=2;/*found*/x=3.0/4;/*found*/while(x !=e) s=s+k*x;k=k* (-1);t=2*i;/*found*/x=(2*i+1)/(t*t);i+;return s;main() double e=1e-3;printf(“nThe result is: %fn“,fun(e);#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) if(d%2=0) *t=d* sl+ *t;sl *= 10;/*found*/s = 10; 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)int i,n=0;for(i=0;si;i+)if(i%2=0 tn=0;main()char s100, t100;void NONO ( );printf(“nPlease 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:n.dat“,“r“) ;wf = fopen(“K:ut.dat“,“w“) ;for(i = 0 ; i unsigned long fun(unsigned long n) unsigned long x=0, s, i; int t;s=n;/*found*/i=1;/*found*/while(s0) t=s%10;if(t%2=0)/*found*/x=x+t*i; i=i*10;s=s/10;return x;main() unsigned long n=-1;while(n99999999|n#define M 5/*found*/int fun(int n, int xx)int fun(int n, int xxMM) int i, j, sum=0;printf( “nThe %d x %d matrix:n“, M, M );for( i = 0; i #include #define N 10typedef struct ss char num10; int s; STU;void fun( STU a, STU *s )STU max;int i;max=a0;for(i=1;ivoid fun( int m, int a10) int i;for (i=0; i 0)/*found*/i = m%10;ai+;/*found*/m = m/10;main() int m, a10,i;printf(“请输入一个整数 : “); scanf(“%d“, fun(m, a);for (i=0; i#define N 4void fun(int aN, int b) int i, j;for (i=0; iaij )bi = aij;main() int aNN=1,4,3,2,8,6,5,7,11,10,12,9,13,16,14,15,bN; int i;fun(a,b);for (i=0; ivoid fun( int *s, int n )/*found*/int i, one=0, zero ; int i, one=0, zero=0 ;for(i=0; i#define N 20void NONO();void fun( char *a , char *s)int i=0;char *p=s;while(*p) ai+=*p; p+;ai=0;main() char s1N, *s2=“abcdefghijk“;fun( s1,s2);printf(“%sn“, s1);printf(“%sn“, s2);NONO();void NONO()/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *fp, *wf ;int i;char s1256, s2256;fp = fopen(“K:n.dat“,“r“) ;wf = fopen(“K:ut.dat“,“w“) ;for(i = 0 ; i #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;void outlist(SLIST *h) SLIST *p;p=h-next;if (p=NULL) printf(“The list is NULL!n“);else printf(“nHead “);do printf(“-%d“, p-data); p=p-next; while(p!=NULL);printf(“-Endn“);#include #include void fun(char *s, char t)int i,n=0;for(i=0;si;i+)if(i%2!=0)tn+=si;tn=0;main()char s100, t100;void NONO ( );printf(“nPlease 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:n.dat“,“r“) ;wf = fopen(“K:ut.dat“,“w“) ;for(i = 0 ; i #include #define N 15void NONO();int fun( int *s, int x)int i,n=-1;for(i=0;i#define N 5typedef struct student long sno;char name10;float score3; STU;void fun(char *filename) FILE *fp; int i, j;STU sN, t;/*found*/fp = fopen(filename, “r”);fread(s, sizeof(STU), N, fp);fclose(fp);for (i=0; isj.sno) t = si; si = sj; sj = t; fp = fopen(filename, “wb“);/*found*/fwrite(s, sizeof(STU), N, fp); /* 二进制输出 */fclose(fp);main() STU tN= 10005,“ZhangSan“, 95, 80, 88, 10003,“LiSi“, 85, 70, 78,10002,“CaoKai“, 75, 60, 88, 10004,“FangFang“, 90, 82, 87,10001,“MaChao“, 91, 92, 77, ssN;int i,j; FILE *fp;fp = fopen(“student.dat“, “wb“);fwrite(t, sizeof(STU), 5, fp);fclose(fp);printf(“nnThe original data :nn“);for (j=0; j#include /*found*/void fun (char s, char t) void fun (char *s, char *t)int i, d;d = strlen(s);for (i = 0; i#include #define N 20int fun( int *b )/*found*/int tN ,i, num int tN ,i, num=0;for(i=0; i=10)/*found*/t+num=bi; tnum+=bi;/*found*/for(i=0; ivoid NONO();int fun(char *s)int i,n=0;for(i=0;si;i+)if(si=0for(i=0; i double fun(int n)double result=1.0;while (n1 n=strlen(s);for(i=0;i/*found*/char fun(char *s, char *t) char *fun(char *s, char *t) int sl=0,tl=0; char *ss, *tt;ss=s; tt=t;while(*ss) sl+;/*found*/(*ss)+;ss+;while(*tt) tl+;/*found*/(*tt)+;tt+;if(tlsl) return t;else return s;main() char a80,b80;printf(“nEnter a string : “); gets(a);printf(“nEnter a string again : “); gets(b);printf(“nThe longer is :nn“%s“n“,fun(a,b);#include double fun(int n) int i; double s, t;/*found*/s=0.0;/*found*/for(i=1; i0): “); scanf(“%d“, printf(“nThe result is: %fn“,fun(n);#include int fun (char *str,char *substr) int i,j,k,num=0;/*found*/for(i = 0, stri, i+) for(i = 0; stri; i+)for(j=i,k=0;substrk=strj;k+,j+)/*found*/If(substrk+1=0) if(substrk+1=0) num+;break;return num;main()char str80,substr80;printf(“Input a string:“) ;gets(str);printf(“Input a substring:“) ;gets(substr);printf(“%dn“,fun(str,substr);#include #include double fun ( double eps)double s,t;int n=1;s=0.0;t=1.0;while(teps)s+=t;t=t*n/(2*n+1);n+;return (2*s);main( ) double x;void NONO ();printf(“Input eps:“) ;scanf(“%lf“, printf(“neps = %lf, PI=%lfn“, x, fun(x);NONO();void NONO ()/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *fp, *wf ;int i ;double x ;fp = fopen(“K:n.dat“,“r“) ;wf = fopen(“K:ut.dat“,“w“) ;for(i = 0 ; i /*found*/void fun ( int a, b ) void fun ( int *a, int *b ) int t;/*found*/t = b; b = a ; a = t; t = *b; *b = *a ; *a = t;main ( ) int a, b;printf ( “Enter a , b : “); scanf ( “%d,%d“, fun ( printf (“ a = %d b = %dn “, a, b
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 班组安全合理化建设制度培训
- 《低压电器》-《低压电器》-项目四 船舶常用泵模块控制
- 2025年教育游戏设计原理
- 财务支付委托协议书
- 货车挂靠经营协议书
- 购买物品退款协议书
- 2025年特种设备监督检验申报办理制度培训
- 颌骨畸形护理查房
- 高血压患者健康管理服务规范考核试题及答案解析
- 拉克囊肿护理查房
- 2023阿里淘宝村报告
- 工程师思维提高
- 如何听如何说:高效能沟通的逻辑与秘诀
- 全国优质课一等奖初中数学七年级下册《实数》公开课精美课件
- GB/T 26162-2021信息与文献文件(档案)管理概念与原则
- 公路工程基本建设项目设计文件编制办法(2022年)正式版本
- 旅游管理信息系统(第二版) 查良松课件 习题指导
- 学口语搞定这88个话题就能说-英语研究中心
- DBJ52-49-2008 贵州省居住建筑节能设计标准
- 感染性疾病的分子生物学检验课件
- 《服饰配件设计》课程教学大纲
评论
0/150
提交评论