C语言程序设计填空改错总结Word文档下载推荐.docx

上传人:b****1 文档编号:15314594 上传时间:2022-10-29 格式:DOCX 页数:21 大小:18.21KB
下载 相关 举报
C语言程序设计填空改错总结Word文档下载推荐.docx_第1页
第1页 / 共21页
C语言程序设计填空改错总结Word文档下载推荐.docx_第2页
第2页 / 共21页
C语言程序设计填空改错总结Word文档下载推荐.docx_第3页
第3页 / 共21页
C语言程序设计填空改错总结Word文档下载推荐.docx_第4页
第4页 / 共21页
C语言程序设计填空改错总结Word文档下载推荐.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

C语言程序设计填空改错总结Word文档下载推荐.docx

《C语言程序设计填空改错总结Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《C语言程序设计填空改错总结Word文档下载推荐.docx(21页珍藏版)》请在冰豆网上搜索。

C语言程序设计填空改错总结Word文档下载推荐.docx

{

t=a%b;

a=b;

b=t;

printf("

greatestcommondivisor:

%d\n"

a);

%最大公约数printf("

leastcommonmultiple:

num1*num2/a);

%最小公倍数

return0;

}

2:

输出字符串长度最大的

string.h>

conio.h>

char*proc(char(*a)[81],intM)

char*max;

inti;

max=a[0];

for(i=1;

i<

M;

i++)

if(strlen(max)<

strlen(a[i]))

max=a[i];

returnmax;

charss[10][81],*max;

intn,i=0;

输入若干个字符串:

"

gets(ss[i]);

puts(ss[i]);

while(!

strcmp(ss[i],"

****"

)==0)

i++;

gets(ss[i]);

puts(ss[i]);

n=i;

max=proc(ss,n);

\nmax=%s\n"

max);

return0;

3:

一/二维数组的定义和初始化

一维数组的定义和初始化

inta[5]={1,2,3,4,5};

二维数组的定义和初始化

inta[3][3]={{1,2,3},{4,5,6},{7,8,9});

inta[3][3]={1,2,3,4,5,6,7,8,9};

inta[3[3]={3*3};

4:

ifelse语句的使用

#include<

inta=3,b=2,c=1;

if(a<

b)

if(b<

0)

c=0;

else

c++;

printf("

c);

return0;

5:

字符常量与C语言中的转义字符

'

\v'

'

0xff'

\017'

A'

0x后面的数是十六进制数

\0后面的数是八进制数

\v是垂直制表

\t是水平制表

6:

跳格输出

charch[2][5]={"

1234"

"

5678"

},*p[2];

inti,j,s=0;

for(i=0;

2;

p[i]=ch[i];

for(j=0;

j<

4;

j++)

s=p[i][j]-'

0'

;

%d"

s);

j++;

7:

关系表达式/逻辑表达式的结果为0或1,0代表假,1代表真。

inta=5,b=6,c=7,d=8,m=2,n=2;

((m=a>

b)&

&

(n=c>

d));

n);

8:

形参值的变化不影响实参

typedefstruct{intb,p;

}A;

voidf(Ac)

intj;

c.b+=1;

c.p+=2;

Aa={1,2};

f(Aa);

%d,%d\n"

a.b,a.p);

输出最大字符串

chara[50],b[30];

scanf("

%s"

strcpy(b,a);

5;

if(strcmp(b,a)<

thelongeststringis%s\n"

b);

thelengthis%d\n"

strlen(b));

9:

冒泡排序

inti,j;

inta[M];

for(j=0;

M-1;

if(a[j]<

a[j+1])

t=a[j];

a[j]=a[j+1];

a[j+1]=t;

选择排序

intt;

intindex;

for(i=0;

index=i;

for(j=i+1;

if(a[i]>

a[j])

index=j;

t=a[i];

a[i]=a[index];

a[index]=t;

经典程序

第2套:

程序改错题

/*************found**************/

voidproc(longs,long*t)

{longs1=10;

s/=10;

*t=s%10;

while(s>

{s=s/100;

*t=s%10*s1+*t;

s1=s1*10;

voidmain()

{

longs,t;

\nPleaseenters:

"

%ld"

s);

proc(s,&

t);

Theresultis:

%ld\n"

t);

程序设计题

voidproc(char*str,chart[])

inti,j=0;

str[i]!

='

\0'

if(i%2==0&

str[i]%2!

t[j++]=str[i];

t[j]='

charstr[100],t[100];

system("

\nPleaseenterstringstr:

str);

proc(str,t);

\nTheresultis:

%s\n"

}

第3套

程序填空题

#defineM10

inti,n=0;

intarr[M]={40,68,62,33,35,52,48,95,

66,73};

intbb[M];

if(arr[i]<

arr[i+1])

bb[n++]=arr[i];

\n***displaybb***\n"

for(i=0;

n;

bb[%d]=%2d"

i,bb[i]);

intm[10];

voidproc(void)

intj;

\nInsubfuncaftercalling\n"

for(j=0;

10;

%d"

m[j]/5);

inti;

Inmainbeforecalling\n"

m[i]=i+20;

m[i]);

proc();

\nInmainaftercalling\n"

m[i]/5);

#defineM16

typedefstruct

{charnum[10];

ints;

}STREC;

voidproc(STRECa[])

STRECt;

if(a[j].s<

a[j+1].s)

a[j+1]t;

voidmain()

STRECstu[M]={{"

GA005"

85},{"

GA003"

76},

{"

GA002"

69},{"

GA004"

GA001"

91},

GA007"

72},{"

GA008"

64},{"

GA006"

87},

GA015"

GA013"

91},{"

GA012"

64},

GA014"

GA011"

66},{"

GA017"

GA018"

GA016"

72}};

proc(stu);

Thedataaftersorted:

i<

i++)

{if(i%4==0)

//每行输出4个学生记录

%s%4d"

stu[i].num,stu[i].s);

第4套

math.h>

doubleproc(doublex[10])

doubleavg=0.0;

doublesum=0.0;

double

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 城乡园林规划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1