fffngzzh • 4年前
#include<iostream>
using namespace std;
int main()
{
int a[1],n;
cin>>n;
cin>>a[n];
cout<<n+a[n]<<endl;
return 0;
}
本机AC线上RE,求助!
评论:
using namespace std; int main() {
int p1,p2,s1,s2,retry=0;
string str[4]={"\0","石头","剪刀","布"};
do
{
s1=s2=0;
int times;
cout<<"玩几局?\n";
cin>>times;
for(int i=1;i<=times;i++)
{
system("cls");
cout<<"1.石头\n"<<"2.剪刀\n"<<"3.布\n";
do{cin>>p1;}while(p1>3||p1<1);
cout<<str[p1]<<'\n';
system("pause");
system("cls");
cout<<"1.石头\n"<<"2.剪刀\n"<<"3.布\n";
do{cin>>p2;}while(p2>3||p2<1);
cout<<str[p2]<<'\n';
system("pause");
system("cls");
switch((p1-p2+3)%3)
{
case 0: cout<<s1<<" : "<<s2<<'\n'; break;
case 1: cout<<s1<<" : "<<++s2<<'\n'; break;
case 2: cout<<++s1<<" : "<<s2<<'\n'; break;
}
system("pause");
system("cls");
if(s1==times/2+1||s2==times/2+1) break;
}
if(s1>s2) cout<<"P1赢了!";
else if(s1>s2) cout<<"P2赢了!";
else cout<<"平局!";
cout<<"\n再来?(Y/N)";
char ch;
do{cin>>ch;}while(ch!='Y'&&ch!='N');
if(ch=='Y')
{
retry=1;
system("cls");
}
else retry=0;
}while(retry);
return 0;
}