//C++로 시작하는 객체지향 프로그래밍 p.213 예제 5.10 - 최고점 학생 출력하기
#include <iostream>
#include <string>
using namespace std;
int main() {
int studentCnt, score, max =-999;
string name, maxName;
cout << "학생 수를 입력하시오." << endl;
cin >> studentCnt;
for (int i = 0; i < studentCnt; i++){
cout << "학생 이름과 점수를 입력하시오." << endl;
cin >> name >> score;
if (score > max) {
max = score;
maxName = name;
}
}
cout << maxName << max << endl;
system("pause");
return 0;
}
댓글 없음:
댓글 쓰기