大一的期末C语言程序设计实验,题目是:循环、数组、函数和结构体程序设计 我自己结合好几个答案编了下~

大一的期末C语言程序设计实验,题目是:循环、数组、函数和结构体程序设计 我自己结合好几个答案编了下~,第1张

#include<stdioh>

#include<mathh>

#include<stdlibh>

#define N 2

typedef struct student

{

int num;

char name;

int score[3];

}Student;

void print(Student myclass[],int length)

{

int i=0,sum=0,sum1=0,sum2=0,max=0;

for(i=0;i<length;i++)

{

printf("num:%d name:%s 数学:%d 英语:%d 自然:%d 平均=%2lf 总分=%d\n",

myclass[i]num,myclass[i]name,myclass[i]score[0],myclass[i]score[1],myclass[i]score[2],(myclass[i]score[0]+myclass[i]score[1]+myclass[i]score[2])/30,(myclass[i]score[0]+myclass[i]score[1]+myclass[i]score[2]));

sum=sum+myclass[i]score[0];

sum1=sum1+myclass[i]score[1];

sum2=sum2+myclass[i]score[2];

if((myclass[i]score[0]+myclass[i]score[1]+myclass[i]score[2])>max)

max=i;

}

printf("平均 数学:%d 英语:%d 自然:%d\n",sum/length,sum1/length,sum2/length);

printf("最高:num:%d name:%s 数学:%d 英语:%d 自然:%d 平均=%2lf 总分=%d\n",

myclass[max]num,myclass[max]name,myclass[max]score[0],myclass[max]score[1],myclass[max]score[2],(myclass[max]score[0]+myclass[max]score[1]+myclass[max]score[2])/30,(myclass[max]score[0]+myclass[max]score[1]+myclass[max]score[2]));

}

void input(Student myclass[],int length)

{

int i=0;

for(i=0;i<length;i++)

{

printf("请输入第%d个学生的信息\n",i+1);

printf("学号");

scanf("%d",&myclass[i]num);

myclass[i]name=(char)malloc(sizeof(char)20);

printf("姓名");

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

printf("数学");

scanf("%d",&myclass[i]score[0]);

printf("英语");

scanf("%d",&myclass[i]score[1]);

printf("自然");

scanf("%d",&myclass[i]score[2]);

}

}

void main()

{

Student myclass[N];

input(myclass,N);

print(myclass,N);

}

可以满足楼主的要求,望采纳!!

我来说说楼主的一些问题,首先你的那段程序,函数应该在外面声明,在main函数里面调用,其次是函数要传入结构体的参数,大概就是这些主要的问题,当然还有一些小的问题,自己找吧!!!

#include <stdioh>

#include <stdlibh>

#include <mathh>

/ run this program using the console pauser or add your own getch, system("pause") or input loop /

int main(int argc, char argv[])

{

  int a,b,c;

  int max,min,mid;

  printf("请输入三角形的三边长度:");

  scanf("%d%d%d",&a,&b,&c);

  max=a>b(a>ca:c):(b>cb:c);

  mid=a>b(b>cb:(a>cc:a)):(b>c(a>ca:c):b);

  min=a>b(b>cc:b):(a>cc:a);

  if(max<mid+min)

  {

   if(a==b||a==c||b==c)

   {

    if(a==b&&a==c)

     printf("这是等边三角形。\n");

    else

     printf("这是等腰三角形。\n");

   }

   

   else

   {

    if(maxmax==minmin+midmid)

     printf("这是一个直角三角形\n");

    else

     printf("这是一个一般的三角形\n");

   }

  }

  else

   printf("构不成三角形\n"); 

system("pause");

return 0;

}

大学的高级语言程序设计大多从C语言开始学,没有基础也不用担心。程序设计说白了就是多编程,到时候学的时候把课本看完了,多找些程序代码看看、在电脑上多敲敲,熟能生巧。大学还有后续比如数据结构、算法都是程序设计的重要后续课程,也要重视。总之,编程是学习计算机的灵魂,要重视,但也无须太过担心。

#include<stdioh>

int main()

{

    double height=0;

    int sex;

    printf("请输入您的性别:1(男 ) 2(女):\n");

    scanf("%d",&sex);

    

    double heightOfFather;

    double heightOfMother;

    printf("请输入您父母的身高:\n");

    scanf("%lf %lf",&heightOfFather,&heightOfMother);

    if(sex==1) height=(heightOfFather+heightOfMother)054;

    else height=(heightOfFather092+heightOfMother)/20;

    

    printf("请问您是否有良好的生活习惯 1(有) 0(没有)\n");

    int  have;

    scanf("%d",&have);

    height = height +haveheight15/1000;

    

    printf("请问您是否喜爱体育运动: 1(喜欢) 0(不喜欢)\n");

    int like;

    scanf("%d",&like);

    height = height +likeheight20/1000;

    

    printf("您的身高应该是:%lf\n",height);

    return 0;

}

请输入您的性别:1(男 ) 2(女):

1

请输入您父母的身高:

178 156

请问您是否有良好的生活习惯 1(有) 0(没有)

1

请问您是否喜爱体育运动: 1(喜欢) 0(不喜欢)

1

您的身高应该是:1867267

dty@ubuntu:~$ /aout

请输入您的性别:1(男 ) 2(女):

2

请输入您父母的身高:

178 156

请问您是否有良好的生活习惯 1(有) 0(没有)

1

请问您是否喜爱体育运动: 1(喜欢) 0(不喜欢)

1

您的身高应该是:1655238

假设第一年存n元,那么年终应当是n=n(1+032%)-200;

第二年也是n=n(1+032%)-200

第三年n=n(1+032%)-200

第四年n=n(1+032%)-200

第五年n=n(1+032%)-200为零

所以n=200/(1+032%)为第四年底,第五年初的数量

第四年初n=(200+第五年初的数量)/(1+032%)

第三年初n=(200+第四年初的数量)/(1+032%)

第二年初n=(200+第三年初的数量)/(1+032%)

第一年初n=(200+第二年初的数量)/(1+032%)

参考下:>

以上就是关于大一的期末C语言程序设计实验,题目是:循环、数组、函数和结构体程序设计 我自己结合好几个答案编了下~全部的内容,包括:大一的期末C语言程序设计实验,题目是:循环、数组、函数和结构体程序设计 我自己结合好几个答案编了下~、大一C语言程序设计题, 选择结构程序设计,在线等,急 答案要详细全面、大一下学期适不适合学高级语言程序设计难不难啊等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/9326048.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存