public:
bool judgeCircle(string moves) {
string moves="0";
for(i==0;i<=moves.size();i++)
{
if(moves[i]=='U')
a=a++;
if(moves[i]='D')
b=b++;
if(moves[i]=='L')
c=c++;
if(moves[i]=='R')
int d=d++;
return (a==b&&c=d);
}
}
};
报错:
class Solution {
public:
bool judgeCircle(string moves) {
string count="0";
for(i==0;i<=moves.size();i++)
{
if(moves[i]=='U')
count[0]++;
if(moves[i]='D')
count[1]++;
if(move1[i]=='L')
count[2]++;
if(moves[i]=='R')
count[3]++;
return (count[0]==count[2]&&count[0]==count[0]);
}
}
};
报错:
第三次改:
class Solution {
public:
bool judgeCircle(string moves) {
string count="0";
for(int i=0;i<=moves.size();i++)
{
if(moves[i]=='U')
count[0]++;
if(moves[i]='D')
count[1]++;
if(moves[i]=='L')
count[2]++;
if(moves[i]=='R')
count[3]++;
return (count[0]==count[2]&&count[0]==count[0]);
}
}
};
报错:
为啥,原来,return要在for循环外面:
class Solution {
public:
bool judgeCircle(string moves) {
string count="0000";
for(int i=0;i<moves.size();i++)
{
if(moves[i]=='U')
count[0]++;
if(moves[i]=='D')
count[1]++;
if(moves[i]=='L')
count[2]++;
if(moves[i]=='R')
count[3]++;
}
return (count[0]==count[1] && count[2]==count[3]);
}
};
而且必须要四个0,编程的各种陋习得改