More actions
imported>Unknown No edit summary |
(Repair batch-0002 pages from live compare) |
||
| Line 7: | Line 7: | ||
ofstream fout("output.txt"); | ofstream fout("output.txt"); | ||
int arr | int arr[20][5]={{0}}; | ||
bool flag = true; | bool flag = true; | ||
| Line 18: | Line 18: | ||
{ | { | ||
temp = fin.get(); | temp = fin.get(); | ||
//fin.get(arr | //fin.get(arr[i][j]); | ||
if(temp == -1) //파일끝일경우 | if(temp == -1) //파일끝일경우 | ||
{ | { | ||
| Line 25: | Line 25: | ||
} | } | ||
else //파일끝이 아닐경우 | else //파일끝이 아닐경우 | ||
arr | arr[i][j]=temp; | ||
} | } | ||
if(flag == false) | if(flag == false) | ||
| Line 34: | Line 34: | ||
{ | { | ||
for(int j=0;j<5;j++) | for(int j=0;j<5;j++) | ||
cout <<arr | cout <<arr[i][j]<<"\t"; | ||
cout << endl; | cout << endl; | ||
} | } | ||
int total | int total[5] = {0}; | ||
for(i = 0;i<20;i++) | for(i = 0;i<20;i++) | ||
for(int j=0;j<5;j++) | for(int j=0;j<5;j++) | ||
total | total[j] += arr[i][j]; | ||
for(i = 0;i<5;i++) | for(i = 0;i<5;i++) | ||
cout << total | cout << total[i] <<"\t"; | ||
cout << endl; | cout << endl; | ||
} | } | ||
Latest revision as of 00:16, 27 March 2026
#include <iostream.h>
#include <fstream.h>
void main()
{
ifstream fin("source.txt");
ofstream fout("output.txt");
int arr[20][5]=Template:0;
bool flag = true;
char temp;
for(int i=0;i<20;i++)
{
for(int j=0;j<5;j++)
{
temp = fin.get();
//fin.get(arr[i][j]);
if(temp == -1) //파일끝일경우
{
flag = false;
break;
}
else //파일끝이 아닐경우
arr[i][j]=temp;
}
if(flag == false)
break;
}
for(i = 0;i<20;i++)
{
for(int j=0;j<5;j++)
cout <<arr[i][j]<<"\t";
cout << endl;
}
int total[5] = {0};
for(i = 0;i<20;i++)
for(int j=0;j<5;j++)
total[j] += arr[i][j];
for(i = 0;i<5;i++)
cout << total[i] <<"\t";
cout << endl;
}