#include <iostream>
#include <fstream>
#include <string>
using namespace std;
typedef struct
{
char name[10];
char hakbun[10];
int K;
int E;
int M;
void output()
{
cout << name << '\t' << hakbun << K << "\t" << E << '\t' << M << endl;
}
} STUDENT;
ifstream in("text1.txt");
void input(STUDENT* c)
{
in >> c->name >> c->hakbun >> c->K>> c->E>> c->M;
}
void output(STUDENT* c) {
cout << c->name << '\t' << c->hakbun << '\t' << c->K << "\t" << c->E <<'\t' << c->E<< endl;
}
void AVE(STUDENT* c){
float ave;
ave = c->K+c->E+c->M /3;
cout << c->name<< ave << endl;
}
void ClassA(STUDENT* c){
float Kave;
float Eave;
float Mave;
float Cave;
Kave += c->K;
Kave = Kave/79;
Eave += c->E;
Eave = Eave/79;
Mave += c->M;
Mave = Mave/79;
Cave= (Kave + Eave + Cave) /3;
cout << "국어 : "<< Kave << " 영어 : " << Eave << " 수학 : "<< Mave << endl << "전과목 평균 : "<< Cave << endl;
}
void main()
{
STUDENT* listptr[90];
int count = 0;
while (!in.eof())
{
listptr[count] = new STUDENT;
input(listptr[count]);
count ++;
}
for(int i=0; i<count; i++)
{
listptr[i] -> output();
}
int menu = 0;
while (menu != 5) {
cout << "(1) 입력한 학생들의 이름 학번, 국영수 성적을 차례대로 모두 보여줌" << endl;
cout << "(2) 입력한 학생들 이름과 국영수 성적 평균을 보여줌" << endl;
cout << "(3) 이 학급의 국영수 평균과 전과목 평균을 보여줌" << endl;
cin >> menu;
if (menu == 1) {
for (int i = 0; i < count; i++)
output(listptr[i]);
}
else if(menu == 2){
for(int i =0; i< count; i++)
AVE(listptr[i]);
}
else if (menu == 3) {
for(int i=0; i < count ; i++){
ClassA(listptr[i]);}
}
}
}
책뒤젹거리면서햇는데
안된다...
제발 수정좀 부탁해두될까나 ㅜ
댓글 0