#include<iostream>
using namespace std;
struct teacher
{
    char name[20];
    int teachage;
    float pay;
};
int main()
{
    int x, y;
    cout << "请输入教师职工的信息\n";
    struct teacher th[5];               //定义结构体数组
    for (x = 0; x < 5; x++)
    {
        cout << "请输入第" << x+1 << "位教师职工的姓名:";
        cin >> th[x].name;
        cout << "请输入第" << x+1 << "位教师职工的教龄:";
        cin >> th[x].teachage;
        cout << "请输入第" << x+1 << "位教师职工的工资总额:";
        cin >> th[x].pay;
        cout << "\n";
    }
    cout << "这5位教师职工的信息如下:\n";
    cout << "姓名\t" << "教龄\t" << "工资总额\n";
    for (y = 0; y < 5; y++)            //输出结构体数组里的元素
    {
        cout << th[y].name << "\t" << th[y].teachage << "\t" << th[y].pay << "\n";
    }
    system("pause");
    return 0;
}
Last modification:December 5th, 2018 at 07:17 pm
如果觉得我的文章对您有帮助,请随意赞赏:)