#include "stdio.h"

int main()
{
	int a;
	char b,c;
	scanf("%d",&a);
	c = getchar();
	scanf("%c",&b);
	printf("%d\n%c\n", a,b);
	return 0;
}

//之所以需要第八行,是因为scanf("%d",&a);
//执行程序时,你输入a,然后回车,实际上缓冲区接受的是两个字符,第一个是'a'第二个是‘\n',
//scanf("%d",&a);只把a从缓冲区中取走,但是'\n'还在缓冲区。如果没有c = getchar();
//这个语句,那么下面的语句scanf("%c",&b);就会直接读取缓冲区中的'\n‘,而不会等到你再去输入字符。

相关文章:

  • 2021-05-20
  • 2021-10-04
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-10-30
  • 2022-12-23
猜你喜欢
  • 2022-01-05
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
相关资源
相似解决方案