C语言 程序阅读题文档格式.docx
- 文档编号:16673784
- 上传时间:2022-11-25
- 格式:DOCX
- 页数:48
- 大小:27.10KB
C语言 程序阅读题文档格式.docx
《C语言 程序阅读题文档格式.docx》由会员分享,可在线阅读,更多相关《C语言 程序阅读题文档格式.docx(48页珍藏版)》请在冰豆网上搜索。
3.#include<
{inta[6]={12,4,17,25,27,16},b[6]={27,13,4,25,23,16},i,j;
for(i=0;
i<
6;
i++){
for(j=0;
j<
j++)if(a[i]==b[j])break;
if(j<
6)printf("
%d"
a[i]);
4252716
4.#include<
{inta[8]={1,0,1,0,1,0,1,0},i;
for(i=2;
8;
i++)a[i]+=a[i-1]+a[i-2];
i++)printf("
1022571320
5.#include<
{ints=1,t=1,a,n;
scanf("
%d%d"
&
a,&
n);
for(inti=1;
n;
i++)
{
t=t*10+1;
s=s+t;
s*=a;
SUM=%d\n"
s);
输入数据:
2,4
SUM=2468
6.#include<
#definePR(x,y)printf("
%s=\t%d\n"
x,y)
{intx=03,y=02,z=01;
PR("
x|y&
z"
x|y&
z);
x^y&
~z"
x^y&
~z);
x&
y&
x&
x=1;
y=-1;
!
x|x"
!
x|x);
~x|x"
~x|x);
x|y&
z=3
x^y&
~z=1
x&
z=0
!
x|x=1、~x|x=-1
7.#include<
{inta[5]={2,4,6,9,12},b[6]={2,3,4,6,8,9};
for(inti=0;
5;
for(intj=0;
j++)
if(*(a+i)==*(b+j))printf("
*(a+i));
2469
8.#include<
#include<
string.h>
voidmain()
{charstr1[]="
*******"
4;
%s\n"
str1);
str1[i]='
'
str1[strlen(str1)-1]='
\0'
输出结果:
*
9.#include<
{chara[5][8];
i++)
j++)
if(i==0||i==4)a[i][j]='
-'
elsea[i][j]='
for(i=1;
i++){a[i][0]='
|'
a[i][5]='
i++)a[i][6]='
-
|
10.#include<
{chara[8],temp;
inti,j;
7;
i++)a[i]='
a'
+i;
3;
temp=a[0];
for(j=1;
j++)a[j-1]=a[j];
a[6]=temp;
a[7]='
a);
b
c
d
e
f
g
a
11.#include<
{inti,j,n;
=i;
j++)printf("
"
n=7-2*i;
=n;
%1d"
n);
7
5
3
1
12.#include<
intj,k;
j++)a[j]='
+j;
a[7]='
j++){
temp=a[6];
for(k=6;
k>
0;
k--)a[k]=a[k-1];
a[0]=temp;
13.#include<
voidprint(int,char,int);
{print(3,'
*'
1);
print(2,'
3);
print(1,'
5);
#'
voidprint(intbegin,charpzf,intn)
{chara[50];
begin;
i++)a[begin+i]=pzf;
a[begin+i]='
#
14.#include<
{inta,b,c,find(int,int,int);
%d%d%d"
b,&
c);
%d\n%d,%d,%d\n"
find(a,b,c),a,b,c);
intfind(inta,intb,intc)
{intu,s,t;
u=((u=(a>
b)?
a:
b)>
c)?
u:
c;
t=((t=(a<
b)<
t:
s=a+b+c-u-t;
a=u;
b=s;
c=t;
returns;
运行时输入:
5–73,输出结果:
3
5,-7,3
15.#include<
voidfun1(intn,inta[][3])
{for(inti=0;
a[i][j]=a[i][j]/a[i][i];
{inta[3][3]={{6,4,2},{8,6,4},{9,6,3}};
fun1(3,a);
a[i][j]);
4
2
16.#include<
intfun3(intm)
{inti;
if(m==2||m==3)return1;
if(m<
2||m%2==0)return0;
for(i=3;
m;
i=i+2)if(m%i==0)return0;
return1;
{intn;
for(n=1;
n<
10;
n++)
if(fun3(n)==1)printf("
2357
17.#include<
voidsub(int*a,int*b,int*c,m,n)
{inti,j;
i++)*(c+i)=*(a+i);
j++,i++)*(c+i)=*(b+j);
{inti,x[5]={1,5,3,8,4},y[3]={9,-4,6},z[8];
sub(x,y,z,5,3);
z[i]);
153849–46
18.#include<
voidsort(char*a[],intn)
{inti,j,l;
char*temp;
n-1;
i++){
l=i;
for(j=i+1;
if(strcmp(a[j],a[l])<
0)l=j;
if(l!
=i){
temp=a[i];
a[i]=a[l];
a[l]=temp;
{char*name[4];
intk;
charch[4][15]={"
morning"
"
afternoon"
night"
evening"
};
for(k=0;
k<
k++)name[k]=ch[k];
sort(name,4);
k++)
name[k]);
afternoon
evening
morning
night
19.#include"
stdio.h"
voidpline(char*a,charc,intl,intn)
l;
i++){*a='
a++;
i++,*a=c,a++);
*a='
{chara[80];
inti;
void(*pf)(char*,char,int,int);
pf=pline;
(*pf)(a,'
$'
5-i,2*i-1);
puts(a);
$
20.#include"
intbinary(intx,inta[],intn)
{intlow=0,high=n-1,mid;
while(low<
=high){
mid=(low+high)/2;
if(x>
a[mid])high=mid-1;
elseif(x<
a[mid])low=mid+1;
elsereturn(mid);
return(-1);
{staticinta[]={4,0,2,3,1};
inti,t,j;
t=a[i];
j=i-1;
while(j>
=0&
&
t>
a[j]){a[j+1]=a[j];
j--;
a[j+1]=t;
printf("
%d\n"
binary(3,a,5));
1
21.#include<
math.h>
{doublef(double,int);
%1f\n"
f(2.0,14));
doublef(doublex,intn)
{doublet;
if(n==1)t=x;
else{
if(n/2*2==n)t=x*f(x,n/2);
elset=x*pow(f(x,n/2),2.0);
returnt;
256.000000
22.#include<
doublex,u,v
doublet(doublea,double(*f)(double))
{return(*f)(a*a);
doublef(doublex)
{return2.0*x;
doubleg(doublex)
{return2.0+x;
{x=4.0;
u=t(x,f);
v=t(x,g);
u=%5.3fv=%5.3f\n"
u,v);
U=32.000v=18.000
23.#include<
{staticstructs1{charc[4],*s;
s1={"
abc"
def"
};
staticstructs2{char*cp;
structs1ss1;
}
s2={"
ghi"
{"
jkl"
mno"
}};
%c,%c\n"
s1.c[0],*s1.s);
%s,%s\n"
s1.c,s1.s);
s2.cp,s2.ss1.s);
++s2.cp,++s2.ss1.s);
a,d
abc,def
ghi,mno
hi,no
24.#include<
structs1{char*s;
structs1*s1p;
{statics1a[]={{"
abcd"
1,a+1},{"
efgh"
2,a+2},{"
ijkl"
3,a}};
2;
%d\n"
--a[i].i);
%c\n"
++a[i].s[3]);
0
e
i
25.#include<
{FILE*fp;
chars1[80],s[]="
abcdefghijklmnop"
fp=fopen("
alf.dat"
wb+"
i=sizeof(s);
fwrite(s,i,1,fp);
rewind(fp);
fread(s1,i,l,fp);
all=%s\n"
s1);
fseek(fp,0,0);
seek1ch=%c\n"
fgetc(fp));
fseek(fp,10,1);
seek2ch=%c\n"
fseek(fp,1,1);
seek3ch=%c\n"
fclose(fp);
All=abcdefghijklmnop
seek1ch=a
seek2ch=l
seek3ch=n
26.#include<
{structT1{charc[4],*s;
structT2{char*cp;
T1ss1;
输出结果为
a,d
abc,def
ghi,mno
hi,no
27.#include<
{structinfo{intdata;
info*pn;
info*base,*p;
base=NULL;
p=newinfo;
p->
data=i+1;
pn=base;
base=p;
p=base;
while(p!
=NULL){printf("
%2d"
p->
data);
p=p->
pn;
输出结果为:
10987654321
28.#include<
voiddel_bk(char*p)
{char*p1;
p1=p;
while(*p1!
='
)
if(*p1=='
*(p1+1)=='
)strcpy(p1,p1+1);
elsep1++;
{char*aa="
aabbccccdddefgh"
aa);
del_bk(aa);
输出结果:
aabbccccdddefgh
aabbccccdddefgh
29.#include<
{intm[]={1,2,3,4,5,6,7,8,9},i,j,k;
k=m[i];
m[i]=m[8-i];
m[8-i]=k;
9;
m[j]);
putchar('
\n'
输出结果为:
923456781
983456721
987456321
987654321
30.#include<
{intx[4][4]={{1,2,3,4},{3,4,5,6},{5,6,7,8},{7,8,9,10}};
*(*(x+i)+j)/=*(*(x+i)+i);
%3d"
*(*(x+i)+j));
输出结果为:
1234
0156
0018
0001
31.#include<
{charline[]="
123456789"
inti,k=strlen(line);
line[k-i]='
puts(line+i);
输出结果为:
123456789
2345678
34567
456
32.#include<
{chara[5][20]={"
123"
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C语言 程序阅读题 语言 程序 阅读