我在写程序时,发现了一个问题:
C++字符串循环输入不了!
```c++
#include<bits/stdc++.h>
#define For(i,a,b) for(int i = a;i < b;i++)
#define ll long long
#define ull unsigned long long
#define loop while(true)
using namespace std;
char str[10000];
char j[27] = "abcdefghijklmnopqrstuvwxyz",m[27] = "fghijklmnopqrstuvwxyzabcde";
int main()
{
int ans;
scanf("%d",&ans);
if(ans == 1)
{
printf("Please enter your string:");
fgets(str,10000,stdin);
int len = strlen(str);
for(int i = 0;i < len;i++)
{
str[i] = m[str[i]-'a'];
}
cout<<"is "<<str<<endl;
}
if(ans == 2)
{
printf("Please enter your string:");
fgets(str,10000,stdin);
int len = strlen(str);
for(int i = 0;i < len;i++)
{
if(str[i] == ' ') continue;
if(str[i]-'a'-5 < 0) str[i] = j[26+(str[i]-'a'-5)];
else str[i] = j[str[i]-'a'-5];
}
cout<<"is "<<str<<endl;
}
return 0;
}
```