U E D R , A S I H C RSS

가위바위보/은지

~cpp 

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

int main()
{
	char name1[20];	char name2[20];
	char * score;
	int num1, num2;
	int win1=0, same1=0, lose1=0;
	int win2=0, same2=0, lose2=0;

	ifstream fin("test1.txt");
	fin.getline(name1, 20);
	fin.getline(name2, 20);

	while (!fin.eof())
	{
		fin >> num1;
		char ch = fin.get();
		fin >> num2;

		if (num1 == num2)
			same1++; same2++;
		
		else if ((num1 == 0 && num2 == 1) || (num1 == 1 && num2 ==2) || (num1 == 2 && num2 == 0))
			win2++;	lose1++;
		
		else
			win1++;	lose2++;
	}

	cout << "=가위바위보 게임=\n"
	cout << name1 << " : " << win1 << "승 " << same1 << "무 " << lose1 << "패\n";
	cout << name2 << " : " << win2 << "승 " << same2 << "무 " << lose2 << "패\n";
	return 0;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:39
Processing time 0.0109 sec