用C语言写假设一个班级有30人,每人信息有姓名,学号,英语,语文,数学三种成绩 用c++编写一个学生类。输出每个学生的姓名、学号、成绩

\u7528java\u5199\u7a0b\u5e8f\uff0c\u5b9a\u4e49\u4e00\u4e2astudent\u7c7b\uff0c\u5305\u542b\u6210\u5458\u53d8\u91cf\u6709\u5b66\u53f7\u3001\u59d3\u540d\u3001\u6027\u522b\u3001\u73ed\u5e72\u90e8\u5426\u3001\u6570\u5b66\u3001\u8bed\u6587\uff1f

public class Student {

/**
* @param args
*/
boolean master; //\u5b9a\u4e49\u6210\u5458\u53d8\u91cf
int num;
String name,sex;
double math,chinese,english,score=0.0,average=0.0;

Student(int num,String name, String sex, boolean ma, double math, double chinese, double english ){ //\u6784\u9020\u65b9\u6cd5
this.num = num;
this.name = name;
this.sex = sex;
this.master = ma;
this.math = math;
this.chinese = chinese;
this.english = english;
}

void score(){ //\u8ba1\u7b97\u603b\u5206\u65b9\u6cd5
score= math+chinese+english;
System.out.println(score);
}
void ave(){ //\u8ba1\u7b97\u5e73\u5747\u5206\u65b9\u6cd5
average = score/3;
System.out.println(average);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s = new Student(101,"kit","male",true,90.0,90.0,90.0); //\u521b\u5efa\u5bf9\u8c61
s.score(); //\u8c03\u7528\u65b9\u6cd5
s.ave();
}

}

#include#includeusing namespace std;class Student{public: Student(string s,int a,int b):name(s),id(a),score(b){} void display();private: string name; int id; int score;};void Student::display(){ cout << "\u59d3\u540d:" << ends << name << endl; cout << "\u5b66\u53f7:" << ends << id << endl; cout << "\u6210\u7ee9:" << ends << score << endl;}int main(){ Student stu("\u5c0f\u660e", 19, 97); stu.display(); system("pause"); return 0;}

#include <stdio.h>
#define maxnumber 3
typedef struct stu{
 int idnumber;
 char name[20];
 double English_score;
 double chinese_score;
 double math_score;
}Student;
void copy1(char *a,char *b)//运用指针操作
{
 while(*a!='\0')
 {
  *(b++)=*(a++);
 }
 *b='\0';
}
void main()
{
 Student student[maxnumber];
 
 for(int i=0;i<maxnumber;i++)
 {
  printf("请输入第%d位学生(学号,名字,语文,英语,数学)
",i+1);
  scanf("%d",&student[i].idnumber);
 // char p[20];
  scanf("%s",student[i].name);
  //copy1(p,student[i].name);
  scanf("%lf%lf%lf",&student[i].chinese_score,&student[i].English_score,&student[i].math_score);
 }
  printf("
 学号 姓名  英语 语文 数学 
");
 for(i=0;i<maxnumber;i++)
 {
  for(int j=0;j<10;j++)
   printf("******");
  printf("
");
 
  printf(" %d %s  %.1f %.1f %.1f
",student[i].idnumber,student[i].name,student[i].English_score,student[i].chinese_score,student[i].math_score);
 }
 for( int j=0;j<10;j++)
   printf("******");
  printf("
");
}

功能已实现了,看截图吧!想要输入更多的成员就改maxnumber的值就行了!

记得加分哦!



#include "stdio.h"
#include "string.h"
struct student
{
char cord[15];
char name[12];
double Chinese;
double Math;
double English;
double average;
double sum;
};
void Input(student *st,int num)
{
int i;
for(i=0;i<num;i++)
{
printf("输入第%d个学生信息:(姓名 学号 语文 数学 英语)",i+1);
  scanf("%s %s %lf %lf %lf",st[i].name,st[i].cord,&st[i].Chinese,&st[i].Math,&st[i].English);
  st[i].sum=st[i].Chinese+st[i].Math+st[i].English;
  st[i].average=st[i].sum/3;
}
/*
for(i=0;i<num;i++)
{
  printf("%s %s %0.2lf %0.2lf %0.2lf
",st[i].name,st[i].cord,st[i].Chinese,st[i].Math,st[i].English);
}*/
}
void Find(student *st,char *fc,int num)
{
int i,m;
m=0;
for(i=0;i<num;i++)
{
if(strcmp(fc,st[i].name)==0)
{
m=1;
printf("姓名:%s,学号:%s,英语:%0.0lf,语文:%0.0lf,数学:%0.0f,总分:%0.0lf,平均:%0.2lf
",st[i].name,st[i].cord,st[i].Chinese,st[i].Math,st[i].English,st[i].sum,st[i].average);
}
}
if(m==0)
printf("没有该学生记录!"); 
}
int main()
{
char ch[12];
struct student st[30];
Input(st,30);
printf("输入待找的学生姓名:"); 
scanf("%s",ch);
Find(st,ch,30);
}


现在的孩纸真聪明 老师布置的作业直接交给摆渡大叔了

要用到链表

  • C璇█ 鏁扮粍涓瓨鏀句簡鏌涓彮绾30鍚嶅鐢熺殑鎴愮哗,姹傝鐝笉鍙婃牸鐜囨槸澶氬皯?
    绛旓細double Score[30];//鎴愮哗鏁扮粍int number=0;for(int i=0;i<30;i++){ if(Score[i]>60.0f)number++;}double Failrate=double(number)/30.0f;//涓嶅強鏍肩巼
  • c璇█,杈撳叆涓涓彮绾(涓嶅皯浜30浜)鐨勬煇闂ㄨ绋嬫垚缁,缁熻涓嶅強鏍间汉鏁(鍒嗘暟灏 ...
    绛旓細include<stdio.h>int main(){ int score,i=0; printf("Please input scores,input -1 to finish:\n"); do{ scanf("%d",&score); if(score>-1 && score<60) i++; }while(score!=-1); printf("There are total %d person(s) who failed the exam.\n",...
  • C璇█鎵鹃敊 棰樼洰:浠庨敭鐩樿緭鍏涓涓彮(涓嶈秴杩30浜)瀛︾敓鏌愰棬璇剧殑鎴愮哗,_鐧惧害...
    绛旓細鍙湁浣犺緭鍏ョ殑鎴愮哗涓鸿礋鏁版椂鎵嶄細鍋滄璁╀綘杈撳叆锛屽洜涓轰綘鏈夊垽鏂瓀hile(a[i-1]>=0);鎵浠ュ鏋滀綘杈撳叆鐨勫ぇ浜庨浂浠栦細涓鐩磋浣犺緭鍏ワ紱鍙﹀浣跨敤getch,搴斿寘鍚ご鏂囦欢#include <conio.h> 瀹屾暣浠g爜 include<stdio.h>#include <conio.h>#define N 30void main(){int a[N],i=0,j,k,m=0,t;do{printf("杈撳叆...
  • 瀛︾敓鎴愮哗绠$悊绯荤粺 C璇█绋嬪簭璁捐 鎬!
    绛旓細瀛︾敓鎴愮哗绠$悊绯荤粺鏄涓涓闈炲父瀹炵敤鐨勭▼搴,濡傛灉鑳藉鎶婄敤鎴疯緭鍏ョ殑鏁版嵁瀛樼洏,涓嬫杩愯鏃惰鍑,灏辨洿鏈夌敤浜嗐傛煇鐝湁鏈澶氫笉瓒呰繃30浜(鍏蜂綋浜烘暟鐢遍敭鐩樿緭鍏)鍙傚姞鏈熸湯鑰冭瘯,鑰冭瘯绉戠洰涓烘暟瀛(MT... 瀛︾敓鎴愮哗绠$悊绯荤粺鏄竴涓潪甯稿疄鐢ㄧ殑绋嬪簭,濡傛灉鑳藉鎶婄敤鎴疯緭鍏ョ殑鏁版嵁瀛樼洏,涓嬫杩愯鏃惰鍑,灏辨洿鏈夌敤浜嗐傛煇鐝湁鏈澶氫笉瓒呰繃30浜(鍏蜂綋浜烘暟...
  • C璇█缂栬緫绋嬪簭
    绛旓細scanf("%f", &a[i]); //杈撳叆30涓鐢熸垚缁 if(i == 0)max = a[i]; //鍒濆鍖栨渶楂樺垎 if(max < a[i]) //鎵惧嚭鏈澶у max = a[i];num += a[i]; //绱姞30鍚嶅鐢熸垚缁 } printf("max score:%d %.2f\n",max,num / 30); //杈撳嚭 } //绁濅綘瀛︿範杩涙锛屾洿...
  • 銆愮揣鎬ユ眰鍔┿ C璇█绋嬪簭璁捐!!!
    绛旓細{ char name[8];float score[4],ave,sum;};void main(){ float avef(float a[],int n);float pjf(struct student c[],int n,int m);int a,i,j;float b[4];struct student st[N],t;printf("璇疯緭鍏ュ鐢熶釜鏁帮紙瀛︾敓涓暟蹇呴』灏忎簬绛変簬30锛夛細");scanf("%d",&a);if(a>=N||a<...
  • c璇█鐢ㄦ暟缁勫鐢熸垚缁╃鐞,涓涓彮涓嶈秴杩30浜,璁$畻鎬诲垎骞冲潎鍒,涓轰粈涔堟垜杩 ...
    绛旓細涓诲嚱鏁 ave,sum 澹版槑涓 int 鍨嬶紝杈撳嚭鏍煎紡瑕佺敤 %d 鑰屼笉鏄 %f.浣犲彲浠ユ敼鐢 printf("...%f\n", (float)ave); printf("...%f\n", (float) sum);=== 浣犵敤 int score[N]; return sum/n; 骞冲潎鍊 鏄暣鏁伴櫎浠ユ暣鏁 寰楁暣鏁帮紝浼氭湁璇樊銆傛渶濂 鐢 float, 绮惧害鍙揪 灏...
  • 姹涓涓狢璇█绋嬪簭鎬庝箞鏍缂栧啓
    绛旓細include<stdio.h> int n=30;int basketball,volleyball,gym,pingpong,tennis;int main(){ char x;int i;for (i=1;i<=30;i++){ scanf("%d",&x); //杈撳叆姣忎綅鍚屽鐨勯変慨椤圭洰 switch (x){ case 'b':basketball++;break; // 绡悆浜烘暟鍔1 case 'v':volleyball++;break; // 鎺掔悆...
  • c璇█缂栫▼棰,姹傚姪澶х!
    绛旓細for(i=0;i<30;i++)//杈撳叆30涓鐢熸垚缁 scanf("%d",&score[i]);for(i=0;i<30;i++)//璁$畻骞冲潎鎴愮哗 s=s+score[i];a=(float )s/30.0;i=0;while(i<30)//鎵惧悇鍒嗘暟娈电殑浜烘暟 {if(score[i]<60)m=m+1;if(60<=score[i]<=69)n=n+1;if(70<=score[i]<=79)=p=p+1;i...
  • C璇█:杈撳叆鐝骇浜烘暟36浜哄強C璇█鎴愮哗,鎵撳嵃鍑哄叏鐝殑骞冲潎鎴愮哗鍜屼笉鍙婃牸浜...
    绛旓細include<stdio.h> int main(){ int a[60],n,sum=0,s=0;printf("璇疯緭鍏ヤ汉鏁:");scanf("%d",&n);//杈撳叆浜烘暟锛沺rintf("璇疯緭鍏%d浜虹殑鎴愮哗:\n",n);for(int i=0;i<n;i++){ scanf("%d",&a[i]);//杈撳叆n涓垚缁╋紱sum+=a[i];} sum/=n;for(int i=0;i<n;i++){ if(a[...
  • 扩展阅读:扫一扫题目出答案 ... 外出游玩组织思路 ... 班级外出游玩活动资源 ... c语言零基础自学 ... 零假设h0答题模板 ... 外出游玩活动任务方面 ... 班级外出游玩任务方面 ... 班级外出游玩活动方案 ... 班级外出游玩活动人员组织 ...

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