U E D R , A S I H C RSS

가위바위보/동기

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

void main()
{
	char name1[7],name2[7];
	char test[4];
	ifstream fin("data1.txt");
	fin.getline(name1,10);
	fin.getline(name2,10);
	cout<<name1<<endl<<name2<<endl;
	int win=0;
	int	draw=0;
	int lose=0;
	while(!fin.eof())//0:가위 1:바위 2:보
	{
		
		fin.getline(test,4);
		if (strcmp(test,"0:0")==0)
			draw++;
		else if (strcmp(test,"1:1")==0)
			draw++;
		else if (strcmp(test,"2:2")==0)
			draw++;
		else if (strcmp(test,"1:0")==0)
			win++;
		else if (strcmp(test,"2:1")==0)
			win++;
		else if (strcmp(test,"0:2")==0)
			win++;
		else if (strcmp(test,"0:1")==0)
			lose++;
		else if (strcmp(test,"1:2")==0)
			lose++;
		else if (strcmp(test,"2:0")==0)
			lose++;
	}
	cout <<win<<" win\t"<<draw<<" draw\t"<<lose<<" lose \n";
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:38
Processing time 0.0120 sec