2005/07/22 ¶
3 2 로그램뎅....대로 는데 러남..ㅡㅜ
2랑 3 러는 1 러나까 당 같데...
가 될까???@,.@
2랑 3 러는 1 러나까 당 같데...
가 될까???@,.@
~cpp
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
#include <vector>
using std::cin; using std::sort;
using std::cout; using std::streamsize;
using std::endl; using std::string;
using std::setprecision; using std::vector;
int main()
{
cout << "Please enter your first name: ";
string name;
cin >> name;
cout << "Hello, " << name << "!" << endl;
cout << "Please enter yourmidterm and final exam grades: ";
double midterm, final;
cin >> midterm >> final;
cout << "Enter all your homework grades, "
"followed by endoffile:";
vector<double> homework;
double x;
while (cin >> x)
homework.push_back(x);
typedef vector<double>::size_type vec_sz; // 기 러1
vec_sz size = homework.size(); // 기 러2
if(size == 0) {
cout << endl << "You must enter your grades. "
"Please try again." << endl;
return 1;
}
sort(homework.begin(),homework.end());
vec_sz mid = size/2; // 기 러3
double median;
median = size %2 == 0 ? (homework[mid] + homework[mid-1])/2
:homework[mid];
streamsize prec = cout.precision();
cout << "Your final grade is " << setprecision(3)
<< 0.2* midterm + 0.4*final + 0.4*median
<< setprecision(prec) << endl;
return 0;
}
Answer.
- VS6가 무는 모르겠나 namespace 가 는 것 같기고, namespace 문다.
를 그대로 고 다면 ZP gcc로 돌리면 됩다. 가 능 로 관로 다.
그렇 고 VS6 고 다면
using 로 된 부 using namespace std; 로 바꾸면 로 동다.
.net 떤 모르겠. - eternalbleu
1들 가고 배는 Dev-CPP가 gcc 기반라는 군. 로 돌려 될 듯 . 고 - eternalbleu
- ... g++ ~ -
- 고로 g++ gcc c++관련 라브러리를 동로 링는 다.
g++ test.cpp -o test
gcc -lstdc++ test.cpp -o test
동 결과를 듯다. - eternalbleu










