谁能告诉我怎么回事,本地运行好好的,结果交上去 CE 了,我想大概是 gets 的锅吧,但是我不知道为什么就不能用 gets?
同理,要考 CSP 了,能不能用 gets 解决类似带空格字符串的问题?
除此之外,不知道我的做法是否完全正确,帮我看看行吗?
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
char str[1000005];
int lin,mac;
int main(){
gets(str);
for(int i=0;i<strlen(str)-1;i++){
if(str[i]=='\\'){
if(str[i+1]=='n'){
lin=1;
}else if(str[i+1]=='r'){
mac=1;
}
}
}
if(lin&&mac){
cout<<"windows";
}else if(lin){
cout<<"linux";
}else if(mac){
cout<<"mac";
}
return 0;
}