Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

HASH구하기/오후근,조재화: Difference between revisions

From ZeroWiki
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[20][5]={{0}};
  int arr[20][5]={{0}};
 
 
  bool flag = true;
  bool flag = true;
Line 18: Line 18:
  {
  {
  temp = fin.get();
  temp = fin.get();
  //fin.get(arr[i][j]);
  //fin.get(arr[i][j]);
  if(temp == -1) //파일끝일경우  
  if(temp == -1) //파일끝일경우  
  {
  {
Line 25: Line 25:
  }
  }
  else                //파일끝이 아닐경우
  else                //파일끝이 아닐경우
  arr[i][j]=temp;
  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[i][j]<<"\t";  
  cout <<arr[i][j]<<"\t";  
  cout << endl;
  cout << endl;
  }
  }
 
 
  int total[5] = {0};
  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[j] += arr[i][j];
  total[j] += arr[i][j];
   
   
  for(i = 0;i<5;i++)
  for(i = 0;i<5;i++)
  cout << total[i] <<"\t";
  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;

}