从键盘连续输入一串数字“123456789”,要求用scanf函数(提示:利用“域宽”和“*” )

从键盘连续输入一串数字“123456789”,要求用scanf函数(提示:利用“域宽”和“*” )输出a=12,b=567,c=9。要求:将本题题目以注释的方式写在程序开头处。用C语言

代码如下
/*
从键盘连续输入一串数字“123456789”,要求用scanf函数(提示:利用“域宽”和“*” )输出a=12,b=567,c=9
*/
#include<stdio.h>
#include"stdlib.h"
int main()
{
int a,b,c;
printf("enter the number :\n");
scanf("%2d%2d%3d%1d%1d",&a,&b,&b,&c,&c);
rewind(stdin);
printf("a=%d,b=%d,c=%d\n",a,b,c);
system("pause");
return 0;
}
其中rewind(stdin);和system("pause");这两句是为了更好展示 非必要可以删除
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-10-12
#include<stdio.h>
int mian()
*从键盘连续输入一串数字“123456789”,要求用scanf函数(提示:利用“域宽”和“*” )*
{
int a:3;
int b:3;
int c:3;
int d:10;
scanf("%d",d);
printf("%d=12,%d=567,%d=9",a,b,c);
return 0;
}*不知道对不对哈*本回答被网友采纳
相似回答