U E D R , A S I H C RSS

가위바위보/재니

작성자의 페이지

02 장재니 Genie

소스

~cpp 
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	ifstream fin("gawi.txt");
	char name[2][7];
	int choose[2], result[3] = {0,};
	fin.getline(name[0],7);
	fin.getline(name[1],7);
	for (int i = 0 ; i < 100 ; i++)
	{
		choose[0] = (int)fin.get();
		fin.get();
		choose[1] = (int)fin.get();
		fin.get();
		if (choose[0] == choose[1])
			result[1]++;
		else if(choose[0] == choose[1] + 1 || choose[0] == choose[1] - 2)
			result[0]++;
		else result[2]++;
	}
	cout << name[0] << "  " << result[0] << " 승 " << result[1] << " 무 " << result[2] << " 패\n";
	cout << name[1] << "  " << 100 - result[0] - result[1] << " 승 " << result[1] << " 무 "
		<< 100 - result[2] - result[1] << " 패\n";
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.1916 sec