#include<stdio.h>
int add(int a,int b,int c){
int d;
d=a+b+c;
return d;
}
int main(){
int x,y,z,sum;
printf("Input three integers:");
scanf("%d.%d.%d",&x,&y,&z);
//输入时间隔符必须与“”内一致,否则出错,若无间隔符号,则用回车和空格表示间隔以输入下一个数值。
sum=add(x,y,z);
printf("sum=%d\n",sum);
return 0;
}
此时的运行结果:
Input three integers:15
sum=15
Input three integers:1.2.3
sum=6
若改为
scanf("%d%d%d",&x,&y,&z);
则运行结果可为:
Input three integers:12
5
6
sum=23
Input three integers:12 12 12
sum=36