C语言编程题:有5个学生,每个学生有3门课成绩,从键盘上输入以上数据(包括学号、姓名、数学语文英 C语言问题求教,有5个学生,每个学生有3门课的成绩,从键盘输...

C\u8bed\u8a00\u7f16\u7a0b\u9898\uff1a\u670910\u4e2a\u5b66\u751f,\u6bcf\u4e2a\u5b66\u751f\u6570\u636e\u5305\u62ec\u5b66\u53f7,\u59d3\u540d,3\u95e8\u8bfe\u7684\u6210\u7ee9,\u4ece\u952e\u76d8\u8f93\u516510\u4e2a\u5b66\u751f\u6570\u636e,

#include(stdio.h)
main()
{struct student
{long number;
char name[20];
float score[4];
}person[10];
int i;
printf("\u8bf7\u8f93\u516510\u540d\u5b66\u751f\u7684\u5b66\u53f7\u3001\u59d3\u540d\u3001\u53ca\u4e09\u95e8\u6210\u7ee9:");
for(i=0;i<10;i++)
scanf("%d,%s,%d,%d,%d",&person[i]->number,person[i]->name,&person->score[0],&person->score[1],&person->score[2]);
for(i=0,i<10;i++)
person->score[3]=(person->score[0]+person->score[1]+person->score[2])/3;
printf("10\u540d\u540c\u5b66\u7684\u60c5\u51b5\u5982\u4e0b\uff1a\n");
for(i=0;i<10;i++)
printf("\u5b66\u53f7\uff1a%d \u59d3\u540d\uff1a%s \u6210\u7ee9\uff1a%d %d %d \u5e73\u5747\u6210\u7ee9\uff1a%d\n",person[i]->number,person[i]->name[20],person->score[0],person->score[1],person->score[2],person->score[3]);
}

\u62d3\u5c55\u8d44\u6599

C\u8bed\u8a00\u662f\u4e00\u95e8\u901a\u7528\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e94\u7528\u5e7f\u6cdb\u3002C\u8bed\u8a00\u7684\u8bbe\u8ba1\u76ee\u6807\u662f\u63d0\u4f9b\u4e00\u79cd\u80fd\u4ee5\u7b80\u6613\u7684\u65b9\u5f0f\u7f16\u8bd1\u3001\u5904\u7406\u4f4e\u7ea7\u5b58\u50a8\u5668\u3001\u4ea7\u751f\u5c11\u91cf\u7684\u673a\u5668\u7801\u4ee5\u53ca\u4e0d\u9700\u8981\u4efb\u4f55\u8fd0\u884c\u73af\u5883\u652f\u6301\u4fbf\u80fd\u8fd0\u884c\u7684\u7f16\u7a0b\u8bed\u8a00\u3002
\u5c3d\u7ba1C\u8bed\u8a00\u63d0\u4f9b\u4e86\u8bb8\u591a\u4f4e\u7ea7\u5904\u7406\u7684\u529f\u80fd\uff0c\u4f46\u4ecd\u7136\u4fdd\u6301\u7740\u826f\u597d\u8de8\u5e73\u53f0\u7684\u7279\u6027\uff0c\u4ee5\u4e00\u4e2a\u6807\u51c6\u89c4\u683c\u5199\u51fa\u7684C\u8bed\u8a00\u7a0b\u5e8f\u53ef\u5728\u8bb8\u591a\u7535\u8111\u5e73\u53f0\u4e0a\u8fdb\u884c\u7f16\u8bd1\uff0c\u751a\u81f3\u5305\u542b\u4e00\u4e9b\u5d4c\u5165\u5f0f\u5904\u7406\u5668\uff08\u5355\u7247\u673a\u6216\u79f0MCU\uff09\u4ee5\u53ca\u8d85\u7ea7\u7535\u8111\u7b49\u4f5c\u4e1a\u5e73\u53f0\u3002

#include #include #define MAXLENGTH 100typedef struct student{int number;char name[MAXLENGTH];double chinese, math, english;struct student *next;}student;int main(){student *head, *tail, *node, *loc, *prev;FILE *fout, *fin;int i;head = tail = NULL;for (i = 0; i next = NULL;printf("\u8f93\u5165\u5b66\u53f7\u3001\u59d3\u540d\u3001\u8bed\u6587\u3001\u6570\u5b66\u3001\u82f1\u8bed\u6210\u7ee9\uff1a\n");scanf("%d %s %lf %lf %lf", &node->number, node->name, &node->chinese, &node->math, &node->english);if (head == NULL)head = tail = node;else//\u5c06\u65b0\u7ed3\u70b9\u63a5\u5230\u94fe\u8868\u5c3e\u90e8{tail->next = node;tail = node;}}fout = fopen("stu.dat", "wb");node = head;while (node != NULL){fwrite(node, sizeof(student), 1, fout);node = node->next;}fclose(fout);node = malloc(sizeof(student));printf("\u8f93\u5165\u8981\u6dfb\u52a0\u7684\u5b66\u751f\u5b66\u53f7\u3001\u59d3\u540d\u3001\u8bed\u6587\u3001\u6570\u5b66\u3001\u82f1\u8bed\u6210\u7ee9\uff1a");scanf("%d %s %lf %lf %lf", &node->number, node->name, &node->chinese, &node->math, &node->english);loc = head;prev = NULL;//\u8981\u63d2\u5165\u4f4d\u7f6e\u7684\u524d\u8d8bwhile (loc != NULL && loc->number number)//\u5bfb\u627e\u63d2\u5165\u4f4d\u7f6e{prev = loc;loc = loc->next;}if (prev == NULL)//\u63d2\u5165\u5230\u94fe\u8868\u5934{node->next = head;head = node;}else{node->next = loc;prev->next = node;}fout = fopen("stu1.dat", "wb");//\u4fdd\u5b58\u5230stu1.datnode = head;while (node != NULL){fwrite(node, sizeof(student), 1, fout);node = node->next;}fclose(fout);node = malloc(sizeof(student));fin = fopen("stu1.dat", "rb");fread(node, sizeof(student), 1, fin);printf("\u5b66\u53f7\uff1a%d \u59d3\u540d\uff1a%s \u8bed\u6587\uff1a%lf \u6570\u5b66\uff1a%lf \u82f1\u8bed\uff1a%lf\n", node->number, node->name, node->chinese, node->math, node->english);while (node->next != NULL){fread(node, sizeof(student), 1, fin);printf("\u5b66\u53f7\uff1a%d \u59d3\u540d\uff1a%s \u8bed\u6587\uff1a%lf \u6570\u5b66\uff1a%lf \u82f1\u8bed\uff1a%lf\n", node->number, node->name, node->chinese, node->math, node->english);}fclose(fin);free(node);//\u56de\u6536\u5185\u5b58while (head != NULL){node = head->next;free(head);head = node;}return 0;}

#include <stdio.h>
#include <stdlib.h> 
#define NAME_MAX 10
#define NUMBER_MAX 10
#define STUDENTS_MAX 5
#define CLEAR_ENTER(array) for(int idx=0;array[idx]!='\0';idx++)\
if(array[idx]=='
')\
array[idx]='\0';
typedef unsigned int Uint32;
typedef struct stu
{
char name[NAME_MAX];
char stu_number[NUMBER_MAX];
Uint32 chinese;
Uint32 math;
Uint32 english;
} stu;

int main(void)
{
stu students[STUDENTS_MAX];
int idx=0;
printf("输入5个学生的信息
");
for(idx=0;idx<STUDENTS_MAX;idx++)
{
printf("name:");
fgets(students[idx].name,NAME_MAX,stdin);
printf("number:");
//fgets(students[idx].stu_number,NUMBER_MAX,stdin);
fgets(students[idx].stu_number,NUMBER_MAX,stdin);
printf("三项分数(语文,数学,英语):");
scanf("%d%d%d",&students[idx].chinese,&students[idx].math,&students[idx].english);
getchar();
}
FILE * fp = fopen("stu.txt","w+");
if(!fp)
return -1;
for(idx=0;idx<STUDENTS_MAX;idx++)
{
printf("name:%s
number:%s
chinese:%d
math:%d
english:%d
",students[idx].name,
students[idx].stu_number,
students[idx].chinese,
students[idx].math,
students[idx].english);
fprintf(fp,"name:%s
number:%s
chinese:%d
math:%d
english:%d
",students[idx].name,
students[idx].stu_number,
students[idx].chinese,
students[idx].math,
students[idx].english);
}
system("pause");
return 0;
}

简单的写了一个,没有调试过。编译通过,Mingw3.4.7.



#include<stdio.h>
int main()
{
void aver(float *p,int n,int m);
int i,j;
float score[5][3];float *p;
p=score[0];
for(i=0;i<5;i++)
{
printf("请输入第%d学生的三门课程的成绩:\n",i+1);
for(j=0;j<3;j++)
scanf("%f\n",&score[i][j]);
}
aver(p,5,3);
}

void aver(float *p,int n,int m)
{
float sum;
int i,j;
for(i=0;i<n;i++)
{sum=0;
for(j=0;j<m;j++)
sum+=*(p+i*m+j);
printf("\n第%d个学生平均成绩:%5.2f\n",i+1,sum/m);
}
}

#include "stdio.h"
struct student
{ char num[6];
char name[8];
int score[3];
float avr;
} stu[5];
main()
{int i,j,sum;
FILE *fp;
/*input*/
for(i=0;i<5;i++)
{ printf("\n please input No. %d score:\n",i);
printf("stuNo:");
scanf("%s",stu[i].num);
printf("name:");
scanf("%s",stu[i].name);
sum=0;
for(j=0;j<3;j++)
{ printf("score %d.",j+1);
scanf("%d",&stu[i].score[j]);
sum+=stu[i].score[j];
}
stu[i].avr=sum/3.0;
}
fp=fopen("stud","w");
for(i=0;i<5;i++)
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}

  • C璇█缂栫▼鐢ㄦ暟缁勮緭鍏5涓鐢鐨勬垚缁╂眰鍑鸿繖浜涘鐢熺殑骞冲潎鎴愮哗,骞惰緭鍑烘墍 ...
    绛旓細usingSystem锛泆singSystem锛嶤ollections锛嶨eneric锛泆singSystem锛嶭inq锛泆singSystem锛嶵ext锛沶amespace锛118锛3锛庯伎4 锝 classProgram 锝 staticvoidMain锛坰tring锛伙冀args锛夛經 int锛伙冀a锛漬ewint锛5锛斤經78锛90锛86锛75锛92锝濓紱doubles锛0锛沠or锛坕nti锛0锛沬锛渁锛嶭ength锛沬锛嬶紜锛夛經 if锛坅锛0锛斤紲a锛籭锛...
  • c璇█缂栧啓绋嬪簭,杈撳叆5涓鍚屽鐨4闂ㄨ鑰冭瘯鎴愮哗,姹傛瘡绉戠殑骞冲潎鎴愮哗鍜屾瘡浣嶅悓瀛...
    绛旓細include<stdio.h> define MP 5//瀛︾敓浜烘暟 5 define MS 4//绉戠洰闂ㄦ暟 4 int main(){ float sum1[MP]={0},sum2[MS]={0};int i,j,scores[MP][MS];for(i=0;i<MP;i++)for(j=0;j<MS;j++)scanf("%d",&scores[i][j]),sum1[i]+=scores[i][j],sum2[j]+=scores[i][j...
  • 路c璇█缂栫▼.5涓鐢鐨勬暟鎹
    绛旓細printf("\n* 5. Exit *");printf("\n***\n\n\n");printf("\nPlease input your choice:");scanf("%d",&choice);return(choice);} void Input(STUDENT *p,int n){ int i;printf("\nPlease input info of students:No Name Math English Computer\n");for (i=0; i<n;...
  • C璇█缂栫▼銆傜敤鏁扮粍瀛樺偍5涓鐢鐨勬煇闂ㄨ鐨勬垚缁╁拰璇ラ棬璇剧殑骞冲潎鎴愮哗,姹傚嚭...
    绛旓細cout << "涓嶅強鏍瀛︾敓淇℃伅濡備笅" << endl;for (int i = 0; i < N; i++){ if (st[i].english < 60 || st[i].math < 60|| st[i].physics <60)cout <<st[i].id << " " << st[i].name <<endl;} } void function5(student st[]){ student temp;for (int i = ...
  • c璇█缂栫▼:杈撳叆5涓鐢3闂ㄨ鐨勬垚缁╄鏂,鏁板,鑻辫,a鍚屽涓夐棬鎴愮哗80,90...
    绛旓細include <stdio.h>double a[11][5]={0};int i,j;void scanfa(double b[11][5]){printf("璇蜂緷娆¤緭鍏ユ瘡浣嶅悓瀛︾殑璇枃銆佹暟瀛︺佽嫳璇殑鎴愮哗:\n");for(i=0;i<5;i++)for(j=0;j<3;j++)scanf("%lf",&b[i][j]);}void SumStu(double b[11][5])//璁$畻杈撳嚭姣忎釜鍚屽鐨勬诲垎{for(i...
  • C璇█缂栫▼--杈撳叆5涓鐢鎴愮哗 鍒ゆ柇鏄惁鍙婃牸
    绛旓細scanf("%d",&score);if(score>60 && score<=100)printf("鎴愮哗鍚堟牸\n");else if(score<60 && score>=0)printf("鎴愮哗涓嶅悎鏍糪n");else printf("杈撳叆鐨勬垚缁╂湁璇痋n");} 渚嬪锛歩nclude<stdio.h> int main(){ int a[5];int i, index = 0;printf("璇疯緭鍏浜斾釜瀛︾敓鐨勬垚缁, 鐢ㄧ┖鏍奸殧寮锛...
  • C璇█缂栫▼!鐢ㄥ鍚,瀛﹀彿,鏁板鎴愮哗鍜岃鏂囨垚缁╂弿杩颁竴涓鐢鐨勬儏鍐点傜紪鍐欑▼...
    绛旓細鐪嬩唬鐮侊細include <stdio.h>typedef struct {char name[20];char id[20];float math_score;float lang_score;}student;#define N 5int main(int argc, char** argv){int i;student stu[N];for (i = 0; i < N; ++i){printf ("杈撳叆绗 %d 涓鐢鐨勪俊鎭紙椤哄簭涓哄鍚嶏紝瀛﹀彿锛屾暟瀛︽垚缁╋紝...
  • C璇█涓袱閬缂栫▼棰姹傛晳!
    绛旓細绗竴棰橈細include<stdio.h> //瀹氫箟涓涓粨鏋勶紝璁板綍涓涓鐢熺殑淇℃伅 typedef struct{ char num[10];char name[10];int score[3];} STUDENT;int main(){ FILE* file; //鏂囦欢鎸囬拡锛岀敤浜庢墦寮鏂囦欢鍜屽皢鏁版嵁鍐欏叆鏂囦欢鐨勪竴涓帴鍙 STUDENT student[5]; //5涓鐢 int i,j;double ave[3]; //璁$畻鍚...
  • 鐢c璇█缂栫▼浠庨敭鐩樿緭鍏5鍚瀛︾敓鏌愮鐩垚缁,瀛樺偍鍦ㄤ竴涓竴缁存暟缁勪腑,姹傚叾骞...
    绛旓細include<stdio.h> int main(){ float a[5],sum,aver;int i;sum=0;printf("please input 5 scores:\n");for(i=0;i<5;i++)scanf("%f",&a[i]);//渚濇杈撳叆5鍚嶅悓瀛︾殑鎴愮哗 for(i=0;i<5;i++)sum+=a[i];aver=sum/5;printf("骞冲潎鎴愮哗涓:%f\n",aver);return 0;} ...
  • C璇█缂栫▼:浠绘剰杈撳叆5涓鐢鎴愮哗,瀵瑰叾杩涜鎺掑簭,鎸夌収浠庡皬鍒板ぇ鐨勯『搴忚緭鍑...
    绛旓細include <stdio.h> include <conio.h> void fun(int a[], int n);void main(void){ int a[5], i;for (i=0; i<5; i++){ scanf("%d",&a[i]);} fun(a, 5);} void fun(int a[], int n){ int i, j, t;for (i=0; i<n; i++){ for (j=0; j<n-i-1;...
  • 扩展阅读:少儿编程学c++值得吗 ... 少儿编程十大品牌 ... 少儿编程一共有几级 ... c++免费视频教程 ... 程序员初级入门自学 ... 最不愁就业的3个专业 ... 免费自学电脑培训班 ... c++入门程序代码 ... 学习c++的视频 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网