c语言习题实验七函数答案 c语言实验六函数答案

急求!!C语言课后习题答案!2

以前上课的时候不想做,现在很想补下,很后悔没好好学习呢~希望楼主好好努力

在大石桥等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站建设、网站设计 网站设计制作定制网站设计,公司网站建设,企业网站建设,成都品牌网站建设,成都全网营销推广,外贸营销网站建设,大石桥网站建设费用合理。

第4道1):

#includestdio.h

void main(void)

{

int i,j,a[80],max,max_i;

printf("please input 10 num!\n");

for(i=0;i10;i++)

scanf("%d",a[i]);

printf("the 10 num is:\n");

for(i=0;i10;i++)

printf("%d\t",a[i]);

for(max=a[0],i=0;i10;i++)

{

if(maxa[i])

{

max=a[i];

max_i=i;

}

}

printf("the max num is:a[%d]=%d\n",max_i+1,max);

getch();

}

2)道:

#includestdio.h

void main(void)

{

int a[3][2],i,j,sum[3];

for(i=0;i3;i++)

{

printf("please input the score of the student %d\n",i+1);

scanf("%d%d",a[i][0],a[i][1]);

sum[i]=a[i][0]+a[i][1];

}

for(i=0;i3;i++)

{

printf("the score of the student %d is:%d\t%d\n",i+1,a[i][0],a[i][1]);

printf("the sum score of the student %d is:%d\n",i+1,sum[i]);

}

getch();

}

3)道:

#includestdio.h

#includestring.h

main()

{

int i;

char string1[80],string2[80];

printf("please input the string 1\n");

scanf("%s",string1);

printf("please input the string 2\n");

scanf("%s",string2);

if(strcmp(string1,string2)==0)

printf("the 2 string is the same\n");

else

printf("the 2 string is different\n");

getch();

}

第5道:

#includestdio.h

main()

{

float c,f;

printf("please input the F\n");

scanf("%f",f);

c=(f-32)*5/9;

printf("the convert result is:%.2f\n",c);

getch();

}

小问:

float convert(float a)

{

float b;

b=(a-32)*5/9;

return b;

}

main()

{

float c,f;

printf("please input the F\n");

scanf("%f",f);

c=convert(f);

printf("the convert result is %.2f\n",c);

getch();

}

第6道:

#includestdio.h

main()

{

int x,y,*p1,*p2;

printf("please input the 2 nums;\n");

scanf("%d%d",x,y);

swap1(x,y);

printf("the swap1 result is:%d\t%d\n",x,y);

p1=x;

p2=y;

swap2(p1,p2);

printf("the swap2 result is:%d\t%d\n",*p1,*p2);

getch();

}

swap1(int x,int y)

{

int temp;

temp=x;

x=y;

y=temp;

}

swap2(int *p1,int *p2)

{

int temp;

temp=*p1;

*p1=*p2;

*p2=temp;

}

6.2)

#include stdio.h

void main()

{

char s[80];/*定义一个数组*/

char c;

printf("which style you want to:\n");/*是\不是|*/

printf("capital ( c ) or uncapital(a):");

c=getchar();

if(c=='c')/*是==不是=*/

strcpy(s,"COMPUTER");

else

strcpy(s,"computer");

puts(s);

getch();

}

第七道

struct student

{

char num[8];

char name[80];

float score;

}stu[4];

main()

{

int i,max,max_i;

for(i=0;i4;i++)

{

printf("input the num of student %d\n",i+1);

scanf("%s",stu[i].num);

printf("input the name of student %d\n",i+1);

scanf("%s",stu[i].name);

printf("input the score of student %d\n",i+1);

scanf("%f",stu[i].score);

}

for(max=stu[0].score,i=0;i4;i++)

{

if(maxstu[i].score)

{

max=stu[i].score;

max_i=i;

}

}

printf("the highest score student is student%d\n",max_i+1);

printf("%s\t%s\t%.2f\n",stu[max_i].num,stu[max_i].name,stu[max_i].score);

getch();

}

第八道:

Java的行不,C++的不记得了。

public class Circle

{

private static double PI=3.14

private double radius;

public Circle(double radius)

{

this.radius=radius;

}

public double Area()

{

return PI*radius*radius;

}

public double Perimeter()

{

return 2*PI*radius;

}

}

C语言实验7 函数1

#include stdio.h

int main ()

{

int ad(int);

int n;

printf("请输入一个测试数:");

while(scanf("%d",n)==1)

if(ad(n))

printf("\t %d 是  素数.\n",n);

else 

printf("\t %d 不是素数.\n",n);

return 0;

}

int ad(int n)

{

int flag=1,i;

for (i=2;i=n/2  flag==1;i++)  // 这里 i=n/2就好了

if(n%i==0)

flag=0;

return (flag);

}

代码有点小问题,参看上面的注释

★C语言,函数部分,第7题

涉及到两个概念:递归调用、变量作用域

fun函数中用的w是全局的,值为3

递归调用返回值为5*4*3*2*1*3=360

主函数定义了w,覆盖了全区的,值为10,所以输出360*10=3600

大学程序设计C语言 实验七的题目

第一题:

有3个错。

1.strupr(name[i]) 改为:strcpy(name[i],strupr(name[i]));

2.if(name[i] name[j])改为:if(strcmp(name[i],name[j])0)

3.strcpy(name[i],str );改为:strcpy(str,name[i]);

第二题:

(1)s[i] != '\0'

(2){ j ++;}else

memcpy(s[i],s[i]+1,strlen(s)-i-1)

第三题:

s[i] = '9' s[i] = '0'

分享名称:c语言习题实验七函数答案 c语言实验六函数答案
转载源于:https://www.cdcxhl.com/article22/dochejc.html

成都网站建设公司_创新互联,为您提供外贸建站商城网站网站设计公司网站维护动态网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

网站建设网站维护公司