当前位置:网站首页>(Niuke) BFS
(Niuke) BFS
2022-06-30 15:01:00 【Rabbit doesn't like radish】

Initial error code :( The compiler submitted said it was a segment error , We don't understand , Woo woo )
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<map>
#include<vector>
using namespace std;
//typedef long long ll;
const int N=5;
int main()
{
string s;
cin>>s;
int flag=0;
int mark;
for(int i=0;i<s.size()-2;i++)
{
if(s[i]=='B'||s[i]=='b')
{
if(s[i+1]=='o'||s[i+1]=='O')
{
if(s[i+2]=='B'||s[i+2]=='b')
{
flag=1;
cout<<i<<endl;
break;
}
}
}
}
if(flag==0)
cout<<"-1"<<endl;
return 0;
}
Correct code 1:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<map>
#include<vector>
using namespace std;
//typedef long long ll;
const int N=5;
int main()
{
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
s[i]=toupper(s[i]);// Capitalize all characters ,tolower Is to make all characters lowercase
}
int mark;
if((mark=s.find("BOB"))!=string::npos)// Look for the first appearance BOB when , first B The subscript
cout<<mark<<endl;
else
cout<<"-1"<<endl;
return 0;
}
Correct code 2:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<map>
#include<vector>
using namespace std;
//typedef long long ll;
const int N=5;
int main()
{
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
s[i]=toupper(s[i]);
}
int flag=0;
for(int i=0;i<s.size();i++)
{
if(s[i]=='B'&&s[i+1]=='O'&&s[i+2]=='B')
{
cout<<i<<endl;
flag=1;
break;
}
}
if(flag==0)
cout<<"-1"<<endl;
return 0;
}
// The feeling is that it is wrong that the characters are not unified into positive and negative case
边栏推荐
- PS cutting height 1px, Y-axis tiling background image problem
- Svn password forgetting solution
- 1149 dangerous goods packaging (25 points)
- Quick sort (C language)
- Average and maximum values of MATLAB matrix
- 中信期货开户麻烦吗安全吗,期货开户手续费是多少,能优惠吗
- CCF Z-scan (full mark code + problem solving ideas) 201412-2
- 1131: genetic correlation
- 1062 talent and virtue (25 points)
- Shangpinhui knowledge points of large e-commerce projects
猜你喜欢

How to realize selective screen recording for EV screen recording

CCF call auction (full mark code + problem solving ideas + skill summary) 201412 - 3

Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications

val_ Loss decreases first and then increases or does not decrease but only increases

day02

ES6 notes

PS dynamic drawing

Clear the route cache in Vue

Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~

LIS error: this configuration section cannot be used in this path
随机推荐
Matlab finds prime numbers within 100
Querywrapper in mybaits plus
1131: genetic correlation
CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
[extensive reading of papers] multimodal attribute extraction
L - Jungle roads (minimum spanning tree)
PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available
How to get palindrome number in MATLAB (using fliplr function)
Experiment 2: stack
LIS error: this configuration section cannot be used in this path
[extensive reading of papers] multi modal sarcasm detection and human classification in code mixed conversations
1134: Legal C identifier query
1133: output family and friends string
Database connection to company database denied
Greedy interval problem (5)
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
1136: password translation
[untitled]
Add attributes to multimode