c语言计算一学年加权平均分
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
功能:计算一整学年的加权平均分,输出各科成绩及加权平均分。流程图:
……
N-S图:
源代码:
#include
void main ()
{
unsigned long No; //学号//
unsigned int Year,Month,Day; //生日//
float Math1,Math2,English1,English2,MilitaryTheory,Chemistry,Physics,theModernHistoryofChina,Computer;
//成绩//
float MathematicalExperiment1,MathematicalExperiment2,Circuit,LinearAlgebra,PrincipleofMarxism; //成绩//
float MentalHealth,EngineeringGraphics,IdeologicalandMoralCultivationandBasicLawEducation; //成绩// float Total,Average,WeightedAverage; //总分、平均分、加权平均分//
printf("input the student's No:");
scanf("%8ld",&No);
printf("input the student's Birthday(YYYY-MM-DD):");
scanf("%4d-%2d-%2d",&Year,&Month,&Day);
printf("input the student's Scores(Math1):");
scanf("%f",&Math1);
printf("input the student's Scores(Math2):");
scanf("%f",&Math2);
printf("input the student's Scores(English1):");
scanf("%f",&English1);
printf("input the student's Scores(English2):");
scanf("%f",&English2);
printf("input the student's Scores(MilitaryTheory):");
scanf("%f",&MilitaryTheory);
printf("input the student's Scores(Chemistry):");
scanf("%f",&Chemistry);
printf("input the student's Scores(Physics):");
scanf("%f",&Physics);
printf("input the student's Scores(theModernHistoryofChina):");
scanf("%f",&theModernHistoryofChina);
printf("input the student's Scores(Computer):");
scanf("%f",&Computer);
printf("input the student's Scores(MathematicalExperiment1):");
scanf("%f",&MathematicalExperiment1);
printf("input the student's Scores(MathematicalExperiment2):");
scanf("%f",&MathematicalExperiment2);
printf("input the student's Scores(Circuit):");
scanf("%f",&Circuit);
printf("input the student's Scores(LinearAlgebra):");
scanf("%f",&LinearAlgebra);
printf("input the student's Scores(PrincipleofMarxism):");
scanf("%f",&PrincipleofMarxism);
printf("input the student's Scores(MentalHealth):");
scanf("%f",&MentalHealth);
printf("input the student's Scores(EngineeringGraphics):");
scanf("%f",&EngineeringGraphics);
printf("input the student's Scores(IdeologicalandMoralCultivationandBasicLawEducation):");
scanf("%f",&IdeologicalandMoralCultivationandBasicLawEducation);
Total=Math1+Math2+English1+English2+MilitaryTheory+Chemistry+Physics+theModernHistoryofChina+Com puter+MathematicalExperiment1+MathematicalExperiment2+Circuit+LinearAlgebra+PrincipleofMarxism+Mental Health+EngineeringGraphics+IdeologicalandMoralCultivationandBasicLawEducation;
Average=Total/17;
WeightedAverage=(5*Math1+5*Math2+3*English1+3*English2+1*MilitaryTheory+3*Chemistry+4*Physics+2 *theModernHistoryofChina+3.5*Computer+0.5*MathematicalExperiment1+0.5*MathematicalExperiment2+5*Cir cuit+3*LinearAlgebra+2.5*PrincipleofMarxism+2*MentalHealth+2.5*EngineeringGraphics+2.5*IdeologicalandMor alCultivationandBasicLawEducation)/(5+5+3+3+1+3+4+2+3.5+0.5+0.5+5+3+2.5+2+2.5+2.5);
printf("\nNo:%8ld\nBirthday:1%4d-%2d-%2d\nMath1:%7.2f\nMath2:%7.2f\nEnglish1:%7.2f\nEnglish2:%7.2f \nMilitaryTheory:%7.2f\nChemistry:%7.2f\nPhysics:%7.2f\ntheModernHistoryofChina:%7.2f\nComputer:%7.2f\n MathematicalExperiment1:%7.2f\nMathematicalExperiment2:%7.2f\nCircuit:%7.2f\nLinearAlgebra:%7.2f\nPrinci pleofMarxism:%7.2f\nMentalHealth:%7.2f\nEngineeringGraphics:%7.2f\nIdeologicalandMoralCultivationandBasic LawEducation:%7.2f\nTotal:%7.2f\nAverage:%7.2f\n\nWeightedAverage:%7.2f\n",No,Year,Month,Day,Math1,Mat h2,English1,English2,MilitaryTheory,Chemistry,Physics,theModernHistoryofChina,Computer,MathematicalExperim ent1,MathematicalExperiment2,Circuit,LinearAlgebra,PrincipleofMarxism,MentalHealth,EngineeringGraphics,Ideo logicalandMoralCultivationandBasicLawEducation,Total,Average,WeightedAverage);
}