用scanf下面的函数输入数据,使a=3,b=7,x=8.5,y=71.82,c1=ˊAˊ,c2=ˊaˊ,问在键盘#includeint main(){int a,b;float x,y;char c1,c2;scanf("%d%d",&a,&b);scanf("%f%f",&x,&y);scanf("%c%c",&c1,&c2);printf("a=%db=%d\n",&a,&b);printf("x=%fy=%f\n",&x

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 06:17:52
用scanf下面的函数输入数据,使a=3,b=7,x=8.5,y=71.82,c1=ˊAˊ,c2=ˊaˊ,问在键盘#includeintmain(){inta,b;floatx,y;charc1,c2

用scanf下面的函数输入数据,使a=3,b=7,x=8.5,y=71.82,c1=ˊAˊ,c2=ˊaˊ,问在键盘#includeint main(){int a,b;float x,y;char c1,c2;scanf("%d%d",&a,&b);scanf("%f%f",&x,&y);scanf("%c%c",&c1,&c2);printf("a=%db=%d\n",&a,&b);printf("x=%fy=%f\n",&x
用scanf下面的函数输入数据,使a=3,b=7,x=8.5,y=71.82,c1=ˊAˊ,c2=ˊaˊ,问在键盘
#include
int main()
{
int a,b;
float x,y;
char c1,c2;
scanf("%d%d",&a,&b);
scanf("%f%f",&x,&y);
scanf("%c%c",&c1,&c2);
printf("a=%db=%d\n",&a,&b);
printf("x=%fy=%f\n",&x,&y);
printf("c1=%cc2=%c\n",&c1,&c2);
return 0;
}
我输入 3 7 8.5 71.82 65 97
出来是
a=1245052b=1245048
x=0.000000y=0.000000
c1=1c2=h哪里错了

用scanf下面的函数输入数据,使a=3,b=7,x=8.5,y=71.82,c1=ˊAˊ,c2=ˊaˊ,问在键盘#includeint main(){int a,b;float x,y;char c1,c2;scanf("%d%d",&a,&b);scanf("%f%f",&x,&y);scanf("%c%c",&c1,&c2);printf("a=%db=%d\n",&a,&b);printf("x=%fy=%f\n",&x
您好,是您的输出格式不对
printf("a=%db=%d\n",&a,&b);
printf("x=%fy=%f\n",&x,&y);
printf("c1=%cc2=%c\n",&c1,&c2);
如果用&,表示的是地址值,然后将地址值按格式输出,这样是不对的
应该将&全部去掉
另外,您对字符c1和c2的输入格式也会产生错误
在输入时改成scanf("%d%d",&c1,&c2);这样你在输入65 和97时才会将其Ascii码给字符,用%c将会给的是字符