====
~cpp class SungJuk // . { private: char m_szName[30]; //. int m_nNumber, m_nKorean, m_nEnglish, m_nMath; //,국,, . int m_nTotal; // 계 . double m_dAvg; //균 . public: SungJuk(); // . SungJuk(const char *name,int nNumber, int nKorean, int nEnglish, int nMath); //. int GetTotal(); //계 . void PrintResult(); //결과 . void TopTotal_Print(); void Top_Print(); // . void TopKorean_Print(); //국 . void TopEnglish_Print(); // . void TopMath_Print(); // . const SungJuk & Top_Avg(const SungJuk &s) const; const SungJuk & Top_Total(const SungJuk & s) const; const SungJuk & Top_Korean(const SungJuk & s) const; const SungJuk & Top_English(const SungJuk & s) const; const SungJuk & Top_Math(const SungJuk & s) const; void Input(int nNumber, char szName[], int nKorean, int nEnglish, int nMath); };
¶
~cpp #include<iostream> using namespace std; #include<iostream> //strcpy() #include"SungJuk.h" SungJuk::SungJuk() { strcpy(m_szName, ""); m_nKorean = 0; m_nEnglish = 0; m_nMath = 0; m_nTotal = 0; m_dAvg = 0.0; } int SungJuk::GetTotal() { return m_nTotal; } void SungJuk::PrintResult() { cout<< " " << m_nNumber << "\t" << m_szName<< "\t" << m_nKorean << "\t" << m_nEnglish << "\t" << m_nMath << "\t" <<m_nTotal << "\t" <<m_dAvg << endl; } void SungJuk::TopTotal_Print() { cout<<"\n " << "\t" << " : "<< m_nNumber << "\n" <<"\t\t"<< " : "<< m_szName << "\n" <<"\t\t"<<" : " << m_nTotal << "\n"; } void SungJuk::TopKorean_Print() { cout<<"\n 국 " << "\t" << " : "<< m_nNumber << "\n" <<"\t\t"<< " : "<< m_szName << endl <<"\t\t"<<"국 : " << m_nKorean << endl; } void SungJuk::TopEnglish_Print() { cout<<"\n " << "\t" << " : "<< m_nNumber << endl <<"\t\t"<< " : "<< m_szName << endl <<"\t\t"<<" : " << m_nEnglish << endl; } void SungJuk::TopMath_Print() { cout<<"\n " << "\t" << " : "<< m_nNumber << endl <<"\t\t"<< " : "<< m_szName << endl <<"\t\t"<<" : " << m_nMath << endl; } const SungJuk & SungJuk::Top_Avg(const SungJuk &s) const { if (s.m_nTotal > m_nTotal) return s; else return *this; } const SungJuk & SungJuk::Top_Korean(const SungJuk &s) const { if (s.m_nKorean > m_nKorean) return s; else return *this; } const SungJuk & SungJuk::Top_English(const SungJuk &s) const { if (s.m_nEnglish > m_nEnglish) return s; else return *this; } const SungJuk & SungJuk::Top_Math(const SungJuk &s) const { if (s.m_nMath > m_nMath) return s; else return *this; } void SungJuk::Input(int nNumber, char szName[], int nKorean, int nEnglish, int nMath) { strcpy(m_szName,szName); m_nNumber = nNumber; m_nKorean = nKorean; m_nEnglish = nEnglish; m_nMath = nMath; m_nTotal = m_nKorean + m_nEnglish + m_nMath; m_dAvg = m_nTotal / 3; } const int caucse = 10; void main() { SungJuk score[caucse]; score[0].Input(1,"Park",85,93,92); score[1].Input(2,"kang",96,93,100); score[2].Input(3,"Jang",87,89,94); score[3].Input(4,"Jung",86,97,93); score[4].Input(5,"Shin",94,90,92); score[5].Input(6,"Lee",89,96,87); score[6].Input(7,"Kim",98,93,96); score[7].Input(8,"Min",83,87,82); score[8].Input(9,"Mun",89,96,92); score[9].Input(10,"Han",91,99,100); for(int i=0; i< caucse; i++) score[i].PrintResult(); }