1 #include<iostream>
2 #include<fstream>
3 #include<string>
4 using namespace std;
5 int main(){
6 ifstream inf;
7 ofstream outf;
8 inf.open("input.txt");
9 outf.open("output.txt");
10 float last_year_rainfall_of_city[9];
11 float current_year_rainfall_of_city[9];
12 string name_of_city[9];
13 int num=0;
14 while(!inf.eof()){
15 inf >> last_year_rainfall_of_city[num];
16 inf >> current_year_rainfall_of_city[num];
17 getline(inf,name_of_city[num]);
18 num++;
19 }
20
21 outf << "City Total" << endl;
22 outf << "----------------------------" << endl;
23 for(int i=0;i<9;i++){
24 outf << name_of_city[i] << "\t\t\t\t" << last_year_rainfall_of_city[i] + current_year_rainfall_of_city[i] << endl;
25 }
26
27 return 0;
28 }
이게 코드고
34.4,Seattle,30.5
22.9,Portland,26.1
12.3,New York,9.4
0.5,Death Valley,1.1
3,Las Vegas,13.8
60,Alajuela,54.3
17.3,San Francisco,20.3
29.5,Dublin,30.8
30.1,Seoul,40.5
이게 텍스트 파일인데
컴파일링 하니까 무한루프걸려서 아무것도 안뜨네ㅠㅠ 뭐가 잘못됐지?
텍스트 앞은 전년도 강수량 뒤는 올해 강수량인데
니가 뽑아내는 순서랑 데이터의 순서를 잘 매칭시켜보거라
이거 순서 안맞음??? 맞는것 같은데