#include
using namespace std;
int main()
{
char str[1000];
int a;
for(int i=0;i<1000;i++)
{
while(scanf("%c",&str[i])!=EOF)
{
a=str[i];
if(a==5)
cout<<"2";
else if(a==2)
cout<<"0";
else if(a==0)
cout<<"5";
}
break;
}
return 0;
}
你输入的是字符,不是整数,所以应该是 if(a=='5')这样子
你会设置断点么? 例如在你的代码段的第二行?
另外,str 是 char 的数组,那么,每一元素都是一个 char, a 是一个 int, 你把 char 变成对应的 int,不能直接赋值, 要用 atoi() 函数。 请查一下: https://so.csdn.net/so/search?spm=1001.2101.3001.4498&q=atoi&t=blog&u=