




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上一、阅读程序写出程序运行结果阅读以下程序并写出其运行结果#include <stdio.h>#include <stdlib.h>int fun(char s,int c) char *q=s; for(; *q; q+) if(*q != c) *(s+)=*q; *s=0; main() static char str="turbo c and borland c+" char ch; fun(str,'c'); printf("str=%sn",str); system("
2、pause");程序的运行结果是str=turbo and Borland +阅读以下程序并写出其运行结果#include <stdio.h>#include <stdlib.h>void fun(int a, int b, long *c) *c=a/10*10+a%10*1000+b/10*100+b%10; main() int a=42,b=25; long c; fun(a, b, &c); printf("The result is: %ldn", c); system("pause");程序的运行结
3、果是 the result is: 2245 请按任意键继续阅读以下程序并写出其运行结果#include <stdio.h>void fun(int *s, int nl, int n2) int i, j, t ; i=nl; j=n2; while(i<j) t=si; si=sj; sj=t; i+; j-; main() int a10=1,2,3,4,5,6,7,8,9,0,k;fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k<10;k+)printf(“%d”,ak); printf(“n”); 程序运行的结果是 P
4、ress any key to continue阅读以下程序并写出其运行结果#include<stdio.h> main() int i=1; while(!(i%2=1)&&(i%3=2)&&(i%5=4)&&(i%6=5)&&(i%7=0) +i; printf("n >> The ladder has %d stages.n",i); 程序的运行结果是阅读以下程序并写出其运行结果#include <stdio.h>#define ROW 3#define COL 4ma
5、in()int matrixAROWCOL=11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22; int matrixBCOLROW;int i,j;printf("%d*%d:n",ROW,COL);for( i=0; i<ROW; i+ ) for( j=0; j<COL; j+ )matrixBji = matrixAij;printf("MatrixB,");printf("%d*%d:n",COL,ROW);for( i=0; i<COL; i+ )for( j=0
6、; j<ROW; j+ )printf("%8d",matrixBij);printf("n");system("pause");程序的运行结果是3*4 Matrix B 4*311 15 1912 16 2013 17 2114 18 22阅读以下程序并写出其运行结果#include <stdio.h>#define N 10main()int primesN;int pc,m,k;printf("n The first %d prime numbers are:n",N);primes0=2;
7、pc =1;m =3;while(pc<N)k=0;while(primesk*primesk<=m)if(m%primesk=0) m+=2; k=1;elsek+;primespc+=m;m+=2;for(k=0;k<pc;k+)printf("%4d",primesk);system("pause");程序的运行结果是the fiest 10 prime numbers are2 3 5 7 11 13 17 19 23 29阅读以下程序并写出其运行结果#include <stdio.h>#include <st
8、ring.h>void fun(char *s ,int n) char *t; int i,j; for(i=0;i<n-1;i+) for(j=i+1;j<n;j+)if(strlen(si)>strlen(sj) t=si;si=sj;sj=t;main() char *ss=“bcc”,”bbcc”,”xy”,”aaaacc”,”aabcc” ;fun(ss,5); printf(“%s,%sn”,ss0,ss4);程序的运行结果是阅读以下程序并写出其运行结果#include <stdio.h>void fun(char *a, char *b) w
9、hile(*a=*) a+; while(*b=*a) b+;a+;main() char *s=”*a*b*”,t80;fun(s,t); puts(t); 程序的运行结果是阅读以下程序并写出其运行结果#include <stdio.h>main() FILE *fp; int a10=1,2,3,i,n;fp=fopen(“dl.dat”,”w”);for(i=0;i<3;i+) fprintf(fp,”%d”,ai);fprintf(fp,”n”);fclose(fp);fp=fopen(“dl.dat”,”r”);fscanf(fp,”%d”,&n);fclo
10、se(fp);printf(“%dn”,n);程序的运行结果是阅读以下程序并写出其运行结果#include<stdio.h> void swap( int *a, int *b ) int *t ; t=a; a=b; b=t; main() int i=3,j=5,*p=&i,*q=&j; swap(p,q); printf(“%d %dn”,*p,*q); 程序的运行结果是阅读以下程序并写出其运行结果int circle(int n, int d)int s=0,m=n;while(m)s=s*d+m%d;m/=d;return s=n;int num=232,
11、27,851;int scale=2,10,16;main()int i,j;for(i=0;i<sizeof(num)/sizeof(num0);i+)for(j=0;j<sizeof(scale)/sizeof(scale0);j+)if(circle(numi,scalej)printf("%d -> (%d) is a Circle Number!n",numi,scalej);elseprintf("%d -> (%d) is not a Circle Number!n",numi,scalej);程序的运行结果是 答案
12、太长不想写阅读以下程序并写出其运行结果#include <stdio.h>#define NULL 0int *search2(int *pa,int *pb,int an,int bn)int *ca,*cb;ca=pa;cb=pb;while(ca<pa+an&&cb<pb+bn)if(*ca<*cb) ca+;else if(*ca>*cb) cb+;elsereturn ca;/*返回在这两个数表中找到相等元素*/return NULL;main( )int *vp,i;int a =1,3,5,7,9,13,15,27,29,37;
13、int b =2,4,6,8,10,13,14,27,29,37;puts("The elements of array a is:");for(i=0;i<sizeof(a)/sizeof(a0);i+)printf(" %d",ai);puts("nThe elements of array b is:");for(i=0;i<sizeof(b)/sizeof(b0);i+)printf(" %d",bi);vp=search2(a,b,sizeof a/sizeof a0,sizeof b/siz
14、eof b0);if(vp) printf("nThe first same number in both arrays is %dn",*vp);else printf("Not found!n");程序的运行结果是阅读以下程序并写出其运行结果#include <stdio.h>main()int i, j;char ch;i=1;while(i<=5)j=1;ch='a'while(j<=i)printf("%2c", ch);ch=ch+1;j+;printf("n")
15、;i+; 程序的运行结果是阅读以下程序并写出其运行结果#include <stdio.h>rest(int a, int n)int i,low,high,t;for(i=0,low=0,high=n-1;i<=high;)if(ai>0)t=ai;ai=ahigh;ahigh=t;high-;else if(ai=0)i+;elset=ai;ai=alow;alow=t;low+;i+;int s=8,4,0,-1,6,0,-5;main()int i;printf("n The arry before rest is:n");for(i=0;i&
16、lt;sizeof(s)/sizeof(s0);i+)printf("%4d",si);rest(s,sizeof(s)/sizeof(s0);printf("n The arry after rest is:n");for(i=0;i<sizeof(s)/sizeof(s0);i+)printf("%4d",si);程序的运行结果是the arry before rest is 8 4 0 -1 6 0 -5 the arry after rest is -5 -1 0 0 6 4 8阅读以下程序并写出其运行结果#includ
17、e <stdio.h>#include <string.h>typedef struct char name9; char sex; float score2; STU;void f( STU a) STU b=“Zhao” ,m,85.0,90.0 ; int i;strcpy(,);a.sex=b.sex;for(i=0;i<2;i+) a.scorei=b.scorei;main() STU c=“Qian”,p,95.0,92.0;f(c); printf(“%s,%c,%2.0f,%2.0fn”,,c.sex,c.sc
18、ore0,c.score1); 程序的运行结果是阅读以下程序并写出其运行结果 #include<stdio.h> main() int x,y,z,j=0; printf("n The possible plans to buy 100 fowls with 100 Yuan are:nn"); for(x=0;x<=20;x+) for(y=0;y<=33;y+) z=100-x-y; if(z%3=0&&5*x+3*y+z/3=100) printf("%2d: cock=%2d hen=%2d chicken=%2dn
19、",+j,x,y,z); 程序的运行结果是阅读以下程序并写出其运行结果#include<stdio.h> void fun(int x) if(x/2>0) fun(x/2); printf(“%d ”,x); main() fun(3); printf(“n”); 程序的运行结果是阅读以下程序并写出其运行结果#define MAX(a,b) (a>b)?a:bmain()int x, y;x=25;y=56;printf("the result is: %dn", MAX(x,y);程序的运行结果是the result is 56阅读以下
20、程序并写出其运行结果 #include <stdio.h>#define ROWS 4#define COLS 4int numsROWSCOLS=1000,1000,1000,1000, 900,500,400,100, 90,50,40,10, 9,5,4,1;char *romsROWSCOLS="m","m","m","m", "cm","d","cd","c", "xc","l&quo
21、t;,"xl","x", "ix","v","iv","i"main(int argc,char *argv )int low=1000,high=1012;char roman25;for(;low<=high;low+)to_roman(low,roman);printf("%dt%sn",low,roman);system("pause");to_roman(int decimal,char roman )int power
22、,index;roman0='0'for(power=0;power<ROWS;power+)for(index=0;index<COLS;index+)while(decimal>=numspowerindex)strcat(roman,romspowerindex);decimal-=numspowerindex;程序的运行结果是1000 m 1001 mi 1002 mii 1003 miii 1004 miv 1005 mv 1006 mvi 1007 mvii 1008 mviii 1009 mix 1010 mx 1011 mxi 1012 mxi
23、i#include<stdio.h> int Fun(int x) static int y = 0;y += x;return y; main() int x = 10, y = 0, k;for(k=0; k<2; k+) y = Fun(x);printf("y = %dn", y); 运行结果是:#include<stdio.h>main ( )char a = "programming" , b = "language" ;char *p1, *p2 ;int i;p1 = a; p2 = b;
24、for (i=0; i<7; i+)if (*(p1+i) = *(p2+i) printf("%c" ,*(p1+i) ;printf("n");运行结果是: #include <stdio.h>main()int a=10; int a=15; printf(“a.1=%d,”,a); printf(“a.2=%dn”,a);运行结果是:#include <stdio.h>main()int i=0; while(1) printf(“*”); i+; if(i<3) break;printf(“n”);运行结果是
25、:int runc(int a,int b)return(a+b);main()int x=2,y=5,z=8,r;r=runc(runc(x,y),z);printf(“%dn”,r);执行结果是: 15阅读以下程序并写出其运行结果#incude <stdio.h>main()int i, n3, n2, n1;i=1;while(i<=99)n3=i/100;n2=(i-n3*100)/10;n1=i%10;if(i%3=0)&&(n2=5|n1=5)printf("%5d", i);i+;程序的运行结果是 15 45 51 54 57
26、 75阅读以下程序并写出其运行结果 main ( ) int a66,i,j ; for (i=1; i<6 ; i+) for (j=1 ; j<6 ; j+) aij=(i/j)*(j/i) ; for (i=1;i<6 ; i+) for (j=1 ; j<6 ; j+) printf(“%2d”,aij) ; printf(“n”); 程序的运行结果是 1000001000001000001000001阅读以下程序并写出其运行结果#include <stdio.h>#include <stdlib.h>struct ks int a; i
27、nt *b ; s4, *p ;main ( ) int n=1, i ; for (i=0 ; i<4; i+) si.a = n ; si.b=&si.a ; n=n+2 ; p=&s0 ; p+ ; printf(“%d, %dn”,(+p)->a,(p+)->a) ;程序的运行结果是阅读以下程序并写出其运行结果#include <stdio.h>void fun(int *s, int nl, int n2) int i, j, t ; i=nl; j=n2; while(i<j) t=si; si=sj; sj=t; i+; j-;
28、 main() int a10=1,2,3,4,5,6,7,8,9,0,k;fun(a,0,3); fun(a,4,9); fun(a,0,9); for(k=0;k<10;k+)printf(“%d”,ak); printf(“n”); 程序运行的结果是阅读以下程序并写出其结果func (int a,int b) static int m=0,i=2; i+=m+1; m=i+a+b; return (m);main ( ) int k=4,m=1,p1,p2; p1=func(k,m) ; p2=func(k,m) ; printf(“%d,%dn”,p1,p2) ;程序的运行结果是
29、 8 17阅读以下程序并写出其运行结果struct man char name20 ; int age ; person = “liming”, 18, “wanghua”, 19,”zhangping”,20 ;main ( ) int old = 0 ; struct man *p=person, *q ; for ( ; p<=&person2; p+) if (old<p->age) q=p ; old=p->age ; printf(“$s %dn”,q->name,q->age) ;程序的运行结果是 zhongping 20阅读以下程序并
30、写出其运行结果 #include<stdio.h> main() int x,y,z,j=0; printf("n The possible plans to buy 100 fowls with 100 Yuan are:nn"); for(x=0;x<=20;x+) for(y=0;y<=33;y+) z=100-x-y; if(z%3=0&&5*x+3*y+z/3=100) printf("%2d: cock=%2d hen=%2d chicken=%2dn",+j,x,y,z); 程序的运行结果是阅读以下程
31、序并写出其运行结果#include<stdio.h> void fun(int x) if(x/2>0) fun(x/2); printf(“%d ”,x); main() fun(3); printf(“n”); 程序的运行结果是阅读以下程序并写出其运行结果#define MAX(a,b) (a>b)?a:bmain()int x, y;x=25;y=56;printf("the result is: %dn", MAX(x,y);程序的运行结果是 没找上答案阅读以下程序并写出其运行结果 #include <stdio.h>#defin
32、e ROWS 4#define COLS 4int numsROWSCOLS=1000,1000,1000,1000, 900,500,400,100, 90,50,40,10, 9,5,4,1;char *romsROWSCOLS="m","m","m","m", "cm","d","cd","c", "xc","l","xl","x", "ix
33、","v","iv","i"main(int argc,char *argv )int low=1000,high=1012;char roman25;for(;low<=high;low+)to_roman(low,roman);printf("%dt%sn",low,roman);system("pause");to_roman(int decimal,char roman )int power,index;roman0='0'for(power=0;powe
34、r<ROWS;power+)for(index=0;index<COLS;index+)while(decimal>=numspowerindex)strcat(roman,romspowerindex);decimal-=numspowerindex;程序的运行结果是 没找上答案阅读以下程序并写出其运行结果#incude <stdio.h>main()int i, n3, n2, n1;i=1;while(i<=99)n3=i/100;n2=(i-n3*100)/10;n1=i%10;if(i%3=0)&&(n2=5|n1=5)printf
35、("%5d", i);i+;程序的运行结果是 没找上答案二填空题,在下列代码段中的空白处填入正确的语句 以下程序求3个整数的最小公倍数,请填空#inlcude <stdio.h>int fun(int, tint , int );main() int x1, x2, x3, i=1, j, x0; printf("input 3 integers:"); scanf("%d%d%d", &x1, &x2, &x3); x0=fun(x1, x2, x3); while(1) j=x0*i; if_j
36、%x1=0&&_j%x2=0&&j%x3=0 _break; i+; printf("Result is %dn",j);int fun(int x, int y, int z) if(x>y && x>z) return x; else if_y>x &&y>z_ return y; else return z;以下程序的功能是计算函数,请填空使程序完整。# include <stdio.h> ;main ( ) float x,y,z,f ; scanf(“%f,%f,%
37、f”,&x,&y,&z); f = fun ( ); f += fun ( ); printf(“f=%d”,f);float fun(float a,float b) return (a/b) ;下述程序用“碾转相除法”计算两个整数m和n的最大公约数。该方法的基本思想是计算m和n相除的余数,如果余数为0则结束,此时的被除数就是最大公约数。否则,将除数作为新的被除数,余数作为新的除数,继续计算m和n相除的余数,判断是否为0,等等,请填空使程序完整。 main ( ) int m,n,w; scanf(“%d,%d”,&m,&n); while (n) w
38、 = m%n ; m = n ; n = m ; printf(“%d”,m);以下函数求s=请填空float fun(int n)int i;double s1=0, s2=_,s3=_, s=0;for(i=1; i<=n; i+)s3=s3*i;s1=_;for(i=1; i<=n; i+)s2=s2+_;_;return s; 下面以下程序输出a, b, c三个变量中的最小值,请填空。 #include <stdio.h>main() int a, b, c, t1, t2; scanf("%d%d%d", &a, &b, &
39、amp;c); t1=a<b?_a:b_; t2=c<t1?_c:t1_; printf("%dn", t2);已知如下公式: 下面程序的功能使根据上述公式输出满足精度要求的eps的值,请填空使程序完整。main ( ) double s = 0.0, eps, t=1.0; int n ; scanf (“%lf”,&eps); for (n=1 ; ; n+) s+=t ; t= ; ;计算1+1/2+1/4+1/50的值,并显示出来。 main() int i=2; float sum=1.0; while(i<= 50 ) sum+=1/
40、double i ; i+=2; printf(“sum=%fn”,sum); Fibonacci数列中的头两个数是1和1,从第三个数开始,每个数等于前两个数之和。下述程序计算此数列的前20个数,且每行输出5个数,请填空。#include <stdio.h> main() int f,f1=1,f2=1; int i; printf(“%6d,%6d”,f1,f2); for (i=3;i<=20;i+) f= f1+f2 ; printf(“%6d”,f); if( !ci%5 )printf(“n”); f1=f2; f2=f ; 以下函数用于求出数组grade中n个值的
41、平均数aver,将大于 aver的值置于数组over中,,返回大于平均数的数值的个数。请填空。int fun(int* grade, intn, int* over) int i, j=0; flaot aver, s=0.0; for(i=0; i<n; i+)s=s+gradei; _; for(i=0; i<n; i+)if(gradei>aver)_=gradei; retrun j; 以下程序从名为 filea.dat 的文本文件中逐个读入字符并显示在屏幕上。请填空:#include<stdio.h> main() FILE *fp; char ch ;
42、 fp=fopen(“filea.dat”,”r ”) ; ch=fgetc(fp) ; whlie( !feof(fp) ) putchar(ch) ; ch=fgetc(fp);putchar(n); fclose(fp); 下面函数的功能是将一个整数字符串转换为一个整数,例如: "1234" 转换为1234,请填空使程序完整。int chnum(char *p) int num=0, k, len, j ; len = strlen(p) ; for ( ; *p!=10 ; p+) k = *p0 ; j=(-len) ; while ( j-!=0 ) k = k
43、*10 ; num = num + k ; return (num);完成以下字符串拷贝函数(将*from串拷贝到*to串):void copy_string(char *from, char *to)for(; *from != '0' _;)_; toi='0' 以下程序从键盘输入10个整数到数组a, 然后依次输出10个数组元素#include <stdio.h>void main() int *p,i,a10; p=a; for(i=0;i<10;i+) scanf("%d",p+); printf("n&q
44、uot;);_; for(_) printf("%d ",*p);所谓“水仙花数”是指一个3位数,其各位数字的立方和等于该数本身。例如,153是一个“水仙花数”,因为153135333。完成以下程序使之可打印出1001000内的全部”水仙花数“。main ( ) int i,j,k,n; printf(“水仙花数”是:”); for (n=100; n<1000; n+)i= n/100; /*取百位数*/ j=_; /*取十位数*/ k=n%10; /*取个位数*/ if (_) printf(“%4d”,n); printf(“n”);以下程序用来求两整数的绝对值
45、和。请填空。#include<stdio.h>void main()int x,y; printf("Please input x,y:"); scanf("%d%d",&x,&y); if (x<0) _ ; if (_) y=-y; printf("n|x|+|y|=%dn",x+y); 以下程序可计算1名学生10门课成绩的平均分,将缺省语句填上。#include<stdio.h>float average(float array10) int i;float aver,sum=array0;for(i=1;i<10;i+) sum += _;aver = sum / 10;return(aver);void main()float score10,aver;int i;printf("n input 10 scores:");for(i=0;i<10;i+) scanf("%f",&scorei);aver= _ ;printf("n average score is %5.2fn",aver);以下程序中函数 fun 的
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 三年级下语文教学设计太阳是大家的
- 邵东二中考试试卷及答案
- 山西高二联考试卷及答案
- 三原职教高考试卷及答案
- 2025至2030年中国贵金属清洗机市场分析及竞争策略研究报告
- 硅冶炼原料选择与配料计算考核试卷
- 矿产勘查项目管理流程与效率提升考核试卷
- 经济型酒店品牌竞争策略考核试卷
- 毛皮服装设计与时尚趋势预测考核试卷
- 社会人文与消费者行为考核试卷
- 《特斯拉汽车供应链管理》课件
- 内河船舶船员基本安全知识考试题库300题(含答案)
- 无人机操控 教学设计公开课教案教学设计课件
- 2024 年普通高等学校招生全国统一考试新课标 I 卷-数学试卷-全国
- 《瑞幸咖啡财务造假案例分析》8400字(论文)
- 安全生产法律法规注册安全工程师考试(初级)试题与参考答案(2024年)一
- (试卷)2024贵州省初中学业水平考试·物理
- 云南省职业技能大赛(健康照护赛项)理论参考试题及答案
- 自然辩证法论述题146题带答案(可打印版)
- DB43T 2534-2022 电力气象服务技术规范
- 工程合伙人协议书范文模板下载电子版
评论
0/150
提交评论