rt.帮别人调代码,给我自己整不会了,可能跟不是自己写的有一定关系
用的万能头 用的 using namespace std; 为蛤会说 gets 没定义呢
题目:
代码:
#include<bits/stdc++.h>
#define max 1000002
using namespace std;
char s[max];
int main()
{
int f = 0;
gets(s);
int lens = strlen(s);
for (int i = 0; i < lens; ++i)
{
if (s[i] == ' ') {
f = 0;
}
else {
f++;
}
if (f % 2 != 0 && s[i] > 'Z') {
s[i] -= 32;
}
}
for (int i =0; i < lens; ++i)
{
printf("%c", s[i]);
}
return 0;
}
错误信息:
/tmp/compiler_8nmzo0_5/src: 在函数‘int main()’中: /tmp/compiler_8nmzo0_5/src:9:5: 错误:‘gets’ was not declared in this scope; did you mean ‘fgets’? 9 | gets(s); | ^~~~ | fgets