U E D R , A S I H C RSS

HASH구하기/오후근,조재화

~cpp 
#include <iostream.h>
#include <fstream.h>

void main()
{
	ifstream fin("source.txt");
	ofstream fout("output.txt");

	int arr[20][5]={{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;

}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:20
Processing time 0.0077 sec