感谢@10175102213教我scanf的用法。居然不能一次读两行,感觉自己C语言白学了。
附C++(?)代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int atk1, atk2, hp1, hp2;
while(scanf("%dvs%d",&hp1,&hp2)!=EOF)
{
scanf("%dvs%d",&atk1,&atk2);
while(hp1>0 && hp2>0)
{
hp1-=atk2;
hp2-=atk1;
}
if(hp1>0) cout<<1<<endl;
else cout<<2<<endl;
}
return 0;
}
……
(这是一道水题,但是这是我在400AC之前的遗留产物,不属于食言(溜
include
include
using namespace std;
int main() {
int hp1 = 0, hp2 = 0, at1 = 0, at2 = 0;
while (scanf(“%dvs%d”, &hp1, &hp2) != EOF) {
scanf(“%dvs%d”, &at1, &at2);
int temp1 = hp1 / at2, temp2 = hp2 / at1;
if (temp1>temp2)
cout << 1 << endl;
else
cout << 2 << endl;
}
return 0;
}
这个更快