scanf获取字符
源码:
#include<stdio.h>
#include<math.h>
int main(void)
{
int a,b,c,d;
printf("please enter three integer;\n");
scanf("%d %d %d",&a, &b ,&c);。
d=sqrt(a*1)+sqrt(b*1)+sqrt(c*1);
printf("%d",d);
return 0;
}
输入:1 4 9 / 16 25 36
输出:6/15
//scanf输入一个字符后可以回车,在输入一个;也可以输入一个后空格再输入一个,都可以识别.因为scanf会自动跳过输入值前的所有空白。
但源码:
#include<stdio.h>
#include<math.h>
int main(void)
{
int a,b,c,d;
printf("please enter three integer;\n");
scanf("%d, %d, %d",&a, &b ,&c);
d=sqrt(a*1)+sqrt(b*1)+sqrt(c*1);
printf("%d",d);
return 0;
}
输入则必须加" , "例如:1,4,9
输出:6
不加则输出 :1