69,379
社区成员
发帖
与我相关
我的任务
分享
在每个最后不带\n的printf后面加fflush(stdout);
在每个不想受接收缓冲区旧内容影响的scanf前面加rewind(stdin);
另外请检查scanf的返回值。
[code=c]//请今后要用
char c;
scanf("%c",&c);
//时,都改为
char s[2];
char c;
scanf("%1s",s);
c=s[0];
//自动跳过一个或多个空格或Tab字符或回车换行,读取下一个字符。
[/code]//请今后要用
char c;
scanf("%c",&c);
//时,都改为
char s[2];
char c;
scanf("%1s",s);
c=s[0];
#include <stdio.h>
int main(void)
{
char chA,chB;
int a,b;
int i = 0;
while (i < 3) {
scanf("%c%3d%c%2d",&chA,&a,&chB,&b);
//getchar();
b += a;
printf("%c%c",chA,chB);
printf("%d\n",b);
i++;
}
return 0;
}
试一下这个,加上和不加的区别。