C语言复习材料_第1页
C语言复习材料_第2页
C语言复习材料_第3页
C语言复习材料_第4页
C语言复习材料_第5页
免费预览已结束,剩余40页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、、选择题9、下列程序段运后变量 S 的值为( S=1 )。Int I,s=1;For(i=1;i<=6;i+)if(i%2)Continue;s+=I;S=110 、下列程序段的运行结果是( D )。Int a10=1,2,3,4,5,6,7,8,9,10;For(i=1;i<=6;i+) Ai+1=ai+1+1;For(i=0;i<10;i+)Printf( “%3d”,ai);A、3 4 5 6 7 8 9 10 9 10B、2 3 4 5 6 7 8 9 9 10C、1 2 3 4 5 6 7 8 9 10D、1 2 4 5 6 7 8 9 9 1011、 若已定义二维

2、数组a33,设a00在数组中的位置为1,则a21在数组中位置应是(C) A 、 9 B、 6 C、 8 D、 712、 下列程序段的运行结果是(C )Char str33= 'a','b','c','d','e','f','g','h','i'Str21= '0'Printf( ”%s”,str);A、 abcdefg0i B、 abcdefg0 C、 abcdefg D、 abcdefghi13、 下列程序的运行结果是(A )。#in

3、clude<>Int num=20;Fun()int num=5;Return -num;Void main()fun();Printf( “%dn”,num);A 、 20B、 4 C、 19D、5a12 地址的是( C )15、若已定义: int a34,*p=a; 则能表示数组元素A、a12B、p6 C、p+6 D、 *(a1+2)16、下列程序段的运行结果是( D )。Int a=1,2,3,4,5,6,7,*p=a;Int n,s=0;For(n=0;n<6;n+) s+=pn+;Printf( “%d”,s);A 、12 B、15 C、16 D、917、下列程序的

4、运行结果是( B )。#include <>Union datafloat I;Char c;Structchar a2;Int I;Union data d;q;Void main()printf( “%dn”,sizeof(q);A、6B、8 C、 7 D、 518、下列程序段的执行结果是( A ) Struct student char name;Int high;Int weight;a3= 'c',163,101,'h',169,124,'x',181,135;Struct student *p;Int I,sum=0;Fl

5、oat aver;P=a;For(i=0;i<3;i+)sum=sum+(p+i)->high;Printf( “%fn ”,sum/;A、 B、 97 C、89 D、19、在对无符号数的位运算中,操作数左移两位相当于( B )A、除以8 B、除以4 C、乘以8 D、乘以420、下列程序运行后,文件的内容是( C )。#include<>Main()File *fp;Char str10= “1 st”,”2 nd”;Fp=fopen(“,”w ”);If(fp!=NULL)Fprintf(fp, ”%s”,str0);Fclose(fp);Fp=fopen(“,”w

6、”);If(fp!=NULL)Fprintf(fp, ”%s”,str1);Fclose(fp);A、2ndB、1 stC、1 st 2 ndD、2 nd 1 st23、若定义: int x=3,y=2,k=5; 则正确的表达式是( A )。A 、x=y/2B、x=y+1=8-kC、x=(y+,y+k)D、k=int(x/y)%1025、下列程序段的运行结果是(B )。A 、+3=4B、 +k=4C、+k=5D 、+k=327、设定义:float x= ,y=;语句()执行后变量x值为。A、 x-=2*yB、 x/=x+yC、 x+=y D、 x*=ya+;A+=i;a+=2;29、下列程序段

7、的运行结果是(B )。Int a6=1,2,i;For (i=2;i<=6;i+)ai=ai-1+ai-2;For(i=0;i<6;i+)Printf(“%3d”,ai);A、 1 2 3 4 5 6 B、 1 2 3 5 8 13 C、 1 2 3 5 6 7 D、 1 2 3 4 5 631、下列程序段运行结果中变量 b的值是(D )。Int b=3;Char s1=”action”,s2=s1;b=strcmp(s1,s2);A、 0 B、 1C、 3 D、 -1A、 7 B、 5C、 4 D、 334、下列程序的运行结果是(B )。Main( )char a= ”cba”,

8、*p;For(p=a;p<a+2;p+)Printf(“%s”,p);A、 abcdcc B、 cbabaC、 cbabaa D、 cba35、若定义;Struct student int num;Int age;Struct student s3=301,18,302,21,303,19;Struct student *p=s; 则表达式的值为 21的是( D )。A 、(p+)->ageB、 (*+p).ageC、(*P+).ageD、 *(+P)->age36、若定:int m=12,n=10,k;语句k=m&n;执行后k的值为(D )。A、 14B、 6 C、

9、 2 D、 839、语句( D )符合 C 语言语法。A、 int a=b=c=25 B、 int a=25,b=25+(c=25 ) C、 int a=25,b=c=a; D、 int a,b=25,c;42、若定义:char c;int afloat x; double y;则表达式c*a+x-y值的数据类型(B )A、 float B、 double C、 char D、 int45、下列程序段执行后 p 的值是( C )。Int a33=3,2,1,3,2,1,3,2,1;For(i=0;i<3;i+)For(j=i+1;j<3;j+)P*=aij;A、 108 B、 12

10、 C、 2 D、 1846、下列程序段的运行结果是( B )。Char str80;Strcpy(str,”university”);Printf(“%d”,strlen(str);A、 8 B、 10 C、 117D、 947、下列叙述正确的是( A )。A、#define是宏定义命令B、程序中使用带参数的宏时,参数类型要与宏定义时一致C、宏名只能包含大写字母和数字字符D、编译预处理命令行必须以分号结束48、若有下列程序段,则叙述正确的是(D )Char a=“fujian “;Char *p;P=a;A、数组a的长度和p所指向的字符串长度相等B、数组a中的内容和指针变量p中的内容相等C、

11、a和p完全相同D、*p与a0相等49、 下列程序段的执行结果是(B )。Typedf union int age;char name10;float weight;class;Struct animalint cat;Class dog;double ani;zoon;Class one;Printf( “%d”,sizeof(struct animal)+sizeof(Class);A、 20 B、 30 C、 22 D、 1050、若定义:int I;enum colorsred,green,blue black;Int a3;( C )是对以下正确语句的正确判断。Ared=black;/

12、*语句 1*/I=green+blue;/* 语句 2*/Red=1;/*语句 3*/A、语句1正确,语句2和语句3错误 B、语句2和语句3正确,语句1错误C、语句1和语句3正确,语句2错误 D、语句1和语句2正确,语句3错误51、下列程序段的运行结果是( A )。#include <>Main( )File *fp;Int a=3,b=5,c=8,k,n;Fp=fopen(“,”w ”);Fprintf(fp, ”%dn”,a);Fprintf(fp, ”%d %dn”,b,c);Fclose(fp);Fp=fopen(“,“r“);Fscanf(fp,”%d*%d*%d ”,&

13、amp;k,&n);Printf(%d %dn“,k,n);Fclose(fp);A、 35 B、 53 C、 8 3 D、 3855、 若已定义:char c='M '则正确的赋值表达式是(A )。A、 c=0x2m B、 c=c%3 C、 c=c+029 D、 c%=56、 下列程序段的运行结果是(A )。Void main( )int x,y,z;X=y=1;z=2;If(!x)+z;Else if(!(x-y)Z=3+z;Else if(y)Z+;ElseZ+=13;Printf( “%dn”,z);A、5 B、 15C、8D、 357、下列程序段运行后变量 m

14、 的值为( A )。Int i,j,m=0;For(i=1;i<=2;i+)For(j=1;j<=3;j+=2)M=m+i+j;A 、14B、10C、12D、1358、 若定义二维数组a33,设a00在数组中的位置为1,则a21在数组中位置应是(D )A、 6B、 9 C、 7 D、 859、若已定义:Char str120= “university”,str220;则( B )语句是正确的。A、 str2=str1 B、 printf( “%c ”,str1 );C、 if(str1+20= =str2) printf( “#n”);D、scanf(“%s”,str2);60、

15、下列程序的运行结果是()。#include <>Int fun(int a44) int I;For(i=0;i<4;i+)Printf(“%2d”,ai1);Printf(“n”);Main( ) int a44=1,2,2,3,1,0,0,0,2,1,0,0,0,1,9,8;Fun(a);答案: 2 0 1 161、下列叙述错误的是( C )。A、宏名可以用小写字母表示B、编译预处理命令行都必须以#号开始C、宏定义只能用大写字母表示D、使用预处理命令“ #includev文件名 >”时,编译系统只在指定的系统目录下查找该文件62、下列程序的运行结果是( A )。#i

16、nclude v>Void main( )char *p= ”Chinese”,*q=p+4;Printf(“%cn”,q-1);A、 n B、 s C、 e D、 i63、下列程序段的运行结果是( B )。#include v>Void main( )struct char x1; int x2;a3= A',1,'B ',2,'c',3;Printf(“%dn”,a0,x1-a1.x1/a2.x2);D 、 40B )是错误的叙述B、 p 是一个结构体类型名A、 55 B、 43C、 8064、若有如下类型说明,则(Typedef str

17、uct int no;Char *name;Int cj;STU,*p;A、 STU 是一个结构体类型名C、 no 是结构体类型 STU 的成员 D、 p 是指向结构体类型 STU 的指针类型名65、若文本文件的内容为”University”(不包含引号),则下列程序段的运行结果是(B)File *fp;Char *str;If(fp=fopen( “,”r”)!=NULL)fgets(str,6,fp);Printf(“%s”,str);A 、UniveB、 Univer C、 Universiyt D、 Univ66、若已定义: char c='B 'int a=8; fl

18、oat x=; 则表达式 c%a+x 的值是( D )已知 A '的ASCII码的十进制值为65A、B、10C、12D、67、若已定义:int s34=1,2,0,1,3,4,5; 则 s22的值是(B )。A、 3B、 1C、 5D、 468、 下列程序的运行结果是(B )。#include <> Fun(m)int m=3;M=+I;Printf(“%d”,m);Main()int m=9,n=6;Fun(n);Printf(“%d”,m);A、9 7 B、 7 9 C、 6 6 D、 6 769、 编译预处理命令的位置可以在(C )。A、主函数内B、print();语

19、句中C、文件开头D、自定义函数内70、若已定义:int *p1,*p2;则(B )是无效的指针运算。A、 P1-p2B、 p1+p2 C、 p1<p2D、 p1>p271、当文件正常关闭时, fclose( )函数的返回值是( D )。A、-1B、一个非 0 值 C、1 D、072、 结构化程序设计三种基本结构中,不包含(C )。A、循环结构B、顺序结构C、嵌套结构D、选择结构73、 下列选项中,均为合法整型常量的是(C )。A、 120 B、 170 C、 -190D、 0x2h-012-018013210x120x181e302574、若定义:int a,b,c;则逗号表达式a

20、=10,b=23,c=a+b的值为(D )。A、 23 B、 66C、 10D、 3375、putchar( )函数的功能是向终端输出( A )。A、单个字符B、字符串C、一串数字D、一个实型变量的值76、能对二维数组a进行正确的初始化的语句是(C )0A、 int a24=1,2,3,4,5,6B、 int a3=1,2,3,5,6C、 int a3=1,2,3,4,5D、 int a2=1,2,3,0,577、下列程序段执行后s的值是(B )oInt k,s=0;Int a33=11,12,13,14,15,16,17,18,19;For(k=0;k<2;k+)S+=akk+1;A、

21、 45 B、 28C、 76 D、 3178、 下列程序的运行结果是(A )。#include <>Int fun(int a,int b) return(a*b);Main( )int x=15,y=2,z;Z=fun(x,y);Printf(“%d*%d=%dn”,x,y,z);A、 15*2=30 B、 x*y=30 C、 0 D、 3079、若有定义Struct studentint num;Char sex;Int age;stu1; 下列叙述错误的是( B )。A、Su1是用户定义的结构体类型变量名B> struct student是结构体类型名C、num, se

22、x, age都是结构体变量stul的成员 D、student是结构体类型名80、若定义;enum t1a1,a2=10,a3,a4=13;则枚举常量a2和a3的值分别是(C )。A、 1 和 2 B、 2和 3 C、 10和 11D、 10和 281、若定义:Typedef unionchar name10;Int age;ustu,*uyour;下列叙述错误的是( B )。A、 ustu 是一个共用体类型名B、 uyour 是一个共用体类型名C、age是共用体类型ustu的成员 D、uyour是指向共用体类型ustu的指针类型名82、若已定义:int a=7,b=6; float m=1;则

23、正确的表达式是( C )。A、 (a+b)+B、 m=float(a)/b C、 a=(b!=5) D、 (a+b)*=m83、若定义:int i=1,j=3;则表达式(+i)+(j-)的值为(B )。A、3B、 5C、 2D、484、 若定义:int a=1,b=2,c=3;则表达式 b>=a&&(a+b)v=c 的值为(C )。A、3B、 2C、 1D、085、 为避免在嵌套的条件语句if.else中产生二义性,C语言规定,else子句总是与(B ) 配对。A、缩进位置相同的if B、其之前最近的未配置if C、其之后最近的if D、同一行上的if86、 下列叙述中错

24、误的是(D )。A、在程序中凡是以#号开始的语句都是预处理命令行B、预处理命令行都必须以#号开始C、下列是正确的宏定义:define R 45 D、C程序在执行过程对预处理命令行进行处理87、若定义:int x=8,y=7 ;语句 printf( %d+%d=%dn”x,y,x+y);执行后的输出结果是(D )。A 、7+8=15 B、8*7 C、15 D、 8+7=15 88、下列程序的运行结果是( B )。Main( )static char a= ”bacdefg”,b= ”adcbehg”;Char *p=a,*q=b;Int I;For(i=0;i<=6;i+)If(*(p+i

25、)= =*(q+i)Printf( “%c”,*(q+i);A 、fdbB、cegC、gecad、 aceg90、下列程序段运行后变量s的值为(C ).Int a=1,2,3,4,5,6,7;Int I,s=1,*p;P=&a2;For(i=0;i<4;i+)S*=*(p+i);A、 210 B、 60 C、 360D、 12093、下列程序段的运行结果是( D )。Char a=”student”;Char b=”work ”;Strcpy(a,b);Printf( “%s %c”,a,a5);A、 stud n B、 stud C、 workD、 work n94、 对于下列

26、程序段,叙述正确的是(A )。Int a=2;Doa+=2;while(!(a!=0);A、循环执行1次B、有语法错误C、循环执行2次 D、是无限循环95、若已定义:Typedef struct stuint num;Char name20;STU;则正确的语句是( D )。A、stu dd2=1, ”chen”,2, ”li ” B 、struct stu bb2=1,chen,2,liC、StU aa2=1, 'chen',2, 'li' D、STU cc2=1, ”chen”,2,”li ” 二、填空题#include ""main()

27、double pi=0;long i, sign=1; for(i=1;i<=10001;i+=2) pi+=*sign/i;sign=/*/pi*=/*/ /*/; printf("%fn",pi);答案:/*/;#include ""main()double pi=0; long i, sign=1; for(i=1;i<=10001;i+=2) pi+=*sign/i;sign=/*/ sign*(-1)pi*=/*/ 4 /*/; printf("%fn",pi);#include <>#include

28、 <> void main()int x;/*/*/;/*/printf("Input an integer: "); scanf("%d",&x);f = /*/ printf("F(x)=%fn",f); getch();/*/ ; 答案: #include <>#include <>void main()int x;/*/ float f; /*/ printf("Input an integer: "); scanf("%d",&x);

29、f = /*/ (abs(x)-2)/(pow(x,2)+1); printf("F(x)=%fn",f);/*/ ;getch();#include <>#include <>int count(/*/ /*/)int n=0;char *p=/*/*/;while(*p) if(*p='a') n+;/*/*/;return n;void main()char s255;printf("Enter a string:");gets(s);printf("Count of a is:%dn",

30、count(s);getch();答案:#include <>#include <>int count(/*/ char a /*/) int n=0;char *p=/*/ a /*/;whi-e(*p)宀 if(*pla-) n+2 P+lh ref urn n八 void main()宀char S-255K prinff(=EnCDr a s=ring=)八gefs(s= prinff(=counf of a iw%2n=counf(s)= geoho八#inc-ude Avvoid main()for(li'rAH2 3T+) g(i%3so - i

31、%7SO)QOQO(i%1_ 宀 prinff(=%5d=三7- hhw )gefcho-n+ if(n%6uuo) prinff>n£#inc-ude Avvoid main()7- PROfor(li'rAa'*/ 1000 3T+) 宀=h( (i%3so - i %7SO)QOQO(i%1_ 若 宀 prinff(=%5d=三n+if(n%6uuo) prinmvrr gecrho八 #inc-ude Av1_ hhw )#include <>void sort(int a, int n) int i, j, k, temp;for( i =

32、 0; i < n-1; i+ ) k = i;for(/*/ /*/; j< n; j+) if(/*/*/) k=j;if( k != i ) temp=/*/ /*/; ak=ai; ai=temp;void main()int a = 50,25,88,32,2,65,7,64;int i,n = sizeof(a)/sizeof(int); sort(a,n);for(i=0;i<n;i+)printf("%d ",ai);printf("n");getch();答案:#include <>#include <

33、;>void sort(int a, int n) int i, j, k, temp;for( i = 0; i < n-1; i+ ) k = i;for(/*/ j=i+1 /*/; j< n; j+) if(/*/ ak<aj /*/) k=j;if( k != i ) temp=/*/ ak /*/; ak=ai; ai=temp;void main()int a = 50,25,88,32,2,65,7,64;int i,n = sizeof(a)/sizeof(int);sort(a,n); for(i=0;i<n;i+)printf("%

34、d ",ai); printf("n"); getch();/*/ #include<> #include/*/ double f(double x) double y;/*/;y=/*/ return (y); void main() double x,y1,y2;printf("Please input x:"); scanf("%lf",&x);y1=f(/*/ /*/); y2=f(sin(x);printf("nf(x+=%.3lf",y1); printf("nf

35、(sinx)=%.3lf",y2);getch(); 答案: #include<> #include/*/ "" /*/ double f(double x) double y;y=/*/ *(x*x)+*x+ /*/; return (y); void main() double x,y1,y2;printf("Please input x:"); scanf("%lf",&x);y1=f(/*/ x+ /*/); y2=f(sin(x);printf("nf(x+=%.3lf",y

36、1); printf("nf(sinx)=%.3lf",y2);getch(); #include"" #define ROW 3 #define COL 4void main()int aROWCOL=2,11,3,5,7,24,8,9,16,10,18,66; int bROWCOL=1,9,5,12,6,11,13,2,15,7,25,56; int c/*/ /*/COL,i,j;for(i=0;i<ROW;i+)for(j=0;j<COL;j+)cij=/*/ /*/for(i=0;i<ROW;i+)for(j=0;j<

37、/*/ /*/;j+) printf("%5d",cij);printf("n");getch();答案:#include""#define ROW 3#define COL 4void main()int aROWCOL=2,11,3,5,7,24,8,9,16,10,18,66;int bROWCOL=1,9,5,12,6,11,13,2,15,7,25,56;int c/*/ ROW /*/COL,i,j;for(i=0;i<ROW;i+)for(j=0;j<COL;j+)/*/cij=/*/ aij-bij;for

38、(i=0;i<ROW;i+)for(j=0;j</*/ COL /*/;j+) printf("%5d",cij);printf("n");getch();#include <>#include <>void main()char s20;int i;printf("Please input a string:");scanf(/*/ /*/,s );i=0;while(si)/*/*/printf("n Target string: %sn", s); getch();答案:

39、#include <>#include <> void main()char s20;int i;printf("Please input a string:"); scanf(/*/ "%s" /*/,s ); i=0;while(si)si=/*/si人3;1*1/*/i+;/*/printf("n Target string: %sn", s); getch();#include <> unsigned long fun(unsigned long n) unsigned long x=0;i

40、nt t=0;while(n) t=n%10;if(t%2=/*/*/)x=/*/*/+t;n=n/10;return x;void main()unsigned long n=-1;scanf("%ld",&n);printf("nThe result is:%ldn",fun(n);getch();答案:#include <>unsigned long fun(unsigned long n)unsigned long x=0;int t=0; while(n) t=n%10; if(t%2=/*/ 1 /*/) x=/*/ x*

41、10 /*/+t;n=n/10; return x;void main()unsigned long n=-1;|n<0) scanf("%ld",&n); printf("nThe result is:%ldn",fun(n);getch();#include <>#include <> double f(double /*/ /*/) return (x*x*x+*x*x+*;void main()float x,x1,x2;double y,y1,y2;doprintf("Input x1,x2:&q

42、uot;); scanf("%f,%f",&x1,&x2);y1=f(x1); y2=f(x2);while(y1*y2>=0);do x=(x1+x2)/2;y=/*/ /*/ (x); y1=f(x1);if(y*y1>0)x1=x;elsex2=/*/*/;while(fabs(y)>=1e-6);printf("Root of Equation is %n",x); getch();答案: #include <>#include <> double f(double /*/ x /*/)

43、return (x*x*x+*x*x+*;void main()float x,x1,x2;double y,y1,y2;doprintf("Input x1,x2:"); scanf("%f,%f",&x1,&x2); y1=f(x1); y2=f(x2);while(y1*y2>=0);dox=(x1+x2)/2;y=/*/ f /*/ (x);y1=f(x1);if(y*y1>0)x1=x;elsex2=/*/ x /*/;while(fabs(y)>=1e-6); printf("Root of Equ

44、ation is %n",x); getch();#include<> void main() int p,q,r; float f;clrscr();printf("Please input p q :");scanf("%d%d",/*/ f=*p/q;r= (int)/*/ printf("n p/q=%f/*/);/*/%10;The first decimal place is: %dn",f,r);getch(); 答案: #include<> void main() int p,q,r;

45、float f;clrscr();printf("Please input p q :");scanf("%d%d",/*/ &p,&q /*/);f=*p/q;r= (int)/*/ ( f*10) /*/%10;printf("n p/q=%fThe first decimal place is: %dn",f,r);getch();#include <>void main() long f=/*/ /*/;int i;for (i=1;i<=13;/*/ /*/)f=f*i;printf(&qu

46、ot;nf=%ld", f);getch();答案:#include <>void main() long f=/*/ /*/;int i;for (i=1;i<=13;/*/ i=i+2 /*/)f=f*i;printf("nf=%ld", f);getch();三、改错题#include <>#include <>#include <>#include <>void main() char str1100, t200;int i, j;/*/ i = 0; /*/clrscr();strcpy(

47、str1, "4AZ18cGe9a0z!");for (i = 0; i<strlen(str1); i+)/*/ if (str1i %2= 0) && (i%2!=0) /*/tj = str1i; j+;tj = '0'printf("n 源字符串为 : %sn", str1);printf("n 满足条件的字符有 : %sn", t); 答案:#include <> #include <>#include <>#include <> void

48、 main() char str1100, t200; int i, j;/*/ j = 0; /*/clrscr();strcpy(str1, "4AZ18cGe9a0z!"); for (i = 0; i<strlen(str1); i+)/*/*/ if (str1i %2= 0) && (i%2=0) tj = str1i;j+;tj = '0'printf("n 源字符串为 : %sn", str1);printf("n 满足条件的字符有 : %sn", t); #include <

49、;> #include <>/*/int fun();/*/ int hen,cock,chicken,n=0;clrscr();for(cock=0;cock<=50;cock+=1)for(hen=0;hen<=100;hen=hen+1) chicken=2*(100-hen-2*cock);/*/ if(cock+hen+chicken=100) /*/ n+;printf("%d->hen:%d,cock:%d,chicken:%dn",n,hen,cock,chicken); if(n=20) getch();return n

50、;void main() int num;num=fun();printf("n 方案数为: %d",num);getch();答案: #include <>#include <> /*/ int fun() /*/ int hen,cock,chicken,n=0; clrscr(); for(cock=0;cock<=50;cock+=1) for(hen=0;hen<=100;hen=hen+1) chicken=2*(100-hen-2*cock);/*/ if(cock+hen+chicken=100) /*/ n+;print

51、f("%d->hen:%d,cock:%d,chicken:%dn",n,hen,cock,chicken); if(n=20) getch();return n;void main() int num;num=fun();printf("n 方案数为: %d",num); getch();#include <> int fun(int *x,int y) int t;t=*x;/*/ x=y; /*/ /*/ return(y); /*/void main() int x=6,y=8; printf("%d,%dn"

52、;,x,y); y=fun(&x,y); printf("%d,%dn",x,y);getch();答案: #include <> int fun(int *x,int y) int t;t=*x;/*/ *x=y;/*/*/ y=t;return y; /*/void main() int x=6,y=8; printf("%d,%dn",x,y); y=fun(&x,y); printf("%d,%dn",x,y); getch();#include <> void main()/*/ in

53、t n,i,bk; /*/ printf("Input a num(1-9):"); scanf("%d",&n); for(i=1;i<=n;i+) for(bk=1;bk<=n;bk+) printf(" ");for(j=1;/*/ j<=i+1 /*/;j+) printf("%d",i);printf("n"); for(i=1;i<=n;i+)for(bk=1;bk<=i;bk+) printf(" ");for(j=1;j&

54、lt;=n-i+1;j+) printf("%d",n-i+1);printf(/*/ "/n" /*/);getch();答案: #include <>void main()/*/ int n,i,j,bk; /*/ printf("Input a num(1-9):"); scanf("%d",&n); for(i=1;i<=n;i+)for(bk=1;bk<=n;bk+) printf(" ");for(j=1;/*/ j<=i /*/;j+) pri

55、ntf("%d",i);printf("n"); for(i=1;i<=n;i+)for(bk=1;bk<=i;bk+) printf(" ");for(j=1;j<=n-i+1;j+) printf("%d",n-i+1);printf(/*/ "n" /*/); getch();#include <>void main()/*/ int a=10; num,mark; /*/char op,es; printf("Input an Expression: a"); scanf("%c%c%d",&op,&es,&num); mark=0;if(es='=')/*/ swich /*/(op)case '+': a=a+num; break;case '-': a=a-num; break;case '*': a=a*num; break

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论