- 问答
为什么string变成char就ac了?
- 2024-2-1 22:04:32 @
#include<bits/stdc++.h>
using namespace std;
//string a,b;
long long me,you;
char a[100000];
int main()
{
// getline(cin,a);
// if(a.length() == 20)
// {
// FLAG:
// getline(cin,b);
// if(b.length() == 20)
// {
// a += b;
// goto FLAG;
// }
// else
// {
// a += b;
// }
// }
for(int i = 0;;i++)
{
cin >> a[i];
if(a[i] == 'E')
{
break;
}
}
long long a_length = strlen(a);
for(int i = 0; i < a_length; i++)
{
if(a[i] == 'E')
{
cout << me << ":" << you << endl;
if((me == 11 && abs(me-you) >= 2)|| (you == 11 && abs(me-you) >= 2))
{
cout << "0:0" << endl;
}
break;
}
else if(me >= 11 || you >= 11)
{
if(abs(me-you) >= 2)
{
cout << me << ":" << you << endl;
me = 0;
you = 0;
}
}
if(a[i] == 'W')
{
me++;
}
else if(a[i] == 'L')
{
you++;
}
}
me = 0;
you = 0;
for(int i = 0; i < a_length; i++)
{
if(a[i] == 'E')
{
cout << me << ":" << you << endl;
if((me == 21 && abs(me-you) >= 2)|| (you == 21 && abs(me-you) >= 2))
{
cout << "0:0" << endl;
}
break;
}
else if(me >= 21 || you >= 21)
{
if(abs(me-you) >= 2)
{
cout << me << ":" << you << endl;
me = 0;
you = 0;
}
}
if(a[i] == 'W')
{
me++;
}
else if(a[i] == 'L')
{
you++;
}
}
return 0;
}
2 comments
-
经开一中2026届11班关泽瑞 LV 6 @ 2024-2-11 18:57:12
f(x)=x^2/3+(10-x^2)^0.5 sin(kπx)
-
2024-2-5 19:20:02@
string是字符串定义,char是字符定义,定义的类型都不同代码运行出来的肯定就不一样啊,不用char也可以用字符数组写
- 1