==헤파==
~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();
}









