求大家帮忙做几道C++编程题,本人刚刚学习的,有点不明白。

来源:百度知道 编辑:UC知道 时间:2024/05/18 01:53:39
1.用结构体存放下表中的数据,然后输出每人的姓名和实发数(基本工资+浮动工资-支出)。
姓名 基本工资 浮动工资 支出
zhao 230.00 400.00 76.00
qian 350.00 120.00 56.00
sun 360.00 500.00 80.00
2.用结构体编一程序,实现输入一个学生的数学期中成绩和数学期末成绩,然后计算其数学平均成绩
3. 用结构体指针编一程序,实现输入三个学生的学号,数学期中成绩和数学期末成绩,然后计算其数学平均成绩并输出成绩表

1.
#include<iostream>
using namespace std;

struct salary{
char name[20];
float base;
float extra;
float expense;
};

struct salary s1={"zhao",230.00,400.00,76.00};
struct salary s2={"qian",350.00,120.00,56.00};
struct salary s3={"sun",360.00,500.00,80.00};

int main(){
cout<<s1.name<<" "<<(s1.base+s1.extra-s1.expense)<<endl;
cout<<s2.name<<" "<<(s2.base+s2.extra-s3.expense)<<endl;
cout<<s3.name<<" "<<(s3.base+s3.extra-s3.expense)<<endl;
return 0;
}

2.
#include<iostream>
using namespace std;

struct score{
float first;
float second;
};

int main(){
struct score s;
float f;
cout<<"Enter the first maths score: ";
cin>>f;
s.first=f;
cout<