15,440
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <conio.h>
#include <iomanip> //限定符setw()头文件
#include <cstring>
using namespace std;
struct Subject{ //定义结构Subject
char id[8];
char caption[20];
char room[10];
}study[3]={ //声明一个结构变量study,并将数据成员以数组方式初始化
"A001", "会计学", "MS6708",
"A002", "成本会计", "MS7321",
"A003", "人力资源", "MS4708"
};
void main()
{
int red;
cout << " 代号\t 科目\t 教室" << endl;
cout << "-----------------------------------" << endl;
for(red = 0; red < 3; red++)
{
cout << setw(5) << study[red].id
<< setw(10) << study[red].caption
<< setw(8) << study[red].room << endl;
}
getch ();
}
char id[8];
char caption[20];
char room[10];