标签:int for oat har scanf class 语言 can pre
7-1 计算工资
#include<stdio.h> int main() { int n,i; scanf("%d",&n); struct cj { char name[10]; float x,y,z; }lcj[1000]; for(i=0;i<n;i++) scanf("%s%f%f%f",&gz[i].name,&gz[i].x,&gz[i].y,&gz[i].z); for(i=0;i<n;i++) printf("%s %.2lf\n",gz[i].name,gz[i].x+gz[i].y-gz[i].z); }
7-2 计算平均成绩
#include<stdio.h> int main() {int i,n; float z=0; scanf("%d",&n); struct stu { char name[10]; float x; char y[10]; }stu1[1000]; for(i=0;i<n;i++) {scanf("%s%s%f",&stu1[i].y,&stu1[i].name,&stu1[i].x); z=z+stu1[i].x;} z=z/n*1.0; printf("%.2f\n",z); for(i=0;i<n;i++) if(stu1[i].x<z) printf("%s %s\n",stu1[i].name,stu1[i].y); }
标签:int for oat har scanf class 语言 can pre
原文地址:https://www.cnblogs.com/aytw/p/8901805.html