#includevoid main(){long int num;int ge,shi,bai,qian,wan,place;printf("Please type your number:");scanf("%ld",&num);wan=num/10000;qian=(num-wan*10000)/1000 ;bai=(num-wan*10000-qian*1000)/100 ;shi=(num-wan*10000-qian*1000-bai*100)/10;ge=num-wan*10000-
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/28 02:17:47
#includevoid main(){long int num;int ge,shi,bai,qian,wan,place;printf("Please type your number:");scanf("%ld",&num);wan=num/10000;qian=(num-wan*10000)/1000 ;bai=(num-wan*10000-qian*1000)/100 ;shi=(num-wan*10000-qian*1000-bai*100)/10;ge=num-wan*10000-
#include
void main()
{
long int num;
int ge,shi,bai,qian,wan,place;
printf("Please type your number:");
scanf("%ld",&num);
wan=num/10000;
qian=(num-wan*10000)/1000 ;
bai=(num-wan*10000-qian*1000)/100 ;
shi=(num-wan*10000-qian*1000-bai*100)/10;
ge=num-wan*10000-qian*1000-bai*100-shi*10;
if(num>9999)
place=5;
printf("%d\n",place);
printf("%d,%d,%d,%d,%d\n",wan,qian,bai,shi,ge);
printf("%d%d%d%d%d\n",ge,shi,bai,qian,wan) ;
else if(num>999)
place=4;
printf("%d\n",place);
printf("%d,%d,%d,%d\n",qian,bai,shi,ge);
printf("%d%d%d%d\n",ge,shi,bai,qian);
else if(num>99)
place=3;
printf("%d\n",place);
printf("%d,%d,%d\n",bai,shi,ge);
printf("%d%d%d\n",ge,shi,bai);
else if(num>9)
place=2;
printf("%d\n",place);
printf("%d,%d\n",shi,ge);
printf("%d%d%\n",ge,shi);
else
place=1;
printf("%d\n",place);
printf("%d\n",ge);
printf("%d\n",ge);
}
但tc总是说misplaced else
不对啊,之前的这个程序也没有用{},但却能正常运行
#include
void main()
{
float i,s;
printf("type i:");
scanf("%f",&i);
if(i
#includevoid main(){long int num;int ge,shi,bai,qian,wan,place;printf("Please type your number:");scanf("%ld",&num);wan=num/10000;qian=(num-wan*10000)/1000 ;bai=(num-wan*10000-qian*1000)/100 ;shi=(num-wan*10000-qian*1000-bai*100)/10;ge=num-wan*10000-
你补充的那个程序,每个if和else if下都只有一条语句啊,所以就不用{}了.看下面的程序,每个if和else if下都有多条语句,而且都是在相应的if条件下执行的,它们外面的{}就必不可少了.
每个if和else if下的几个语句要用花括号括起来:
...
if(num>9999)
{
place=5;
printf("%d\n",place);
printf("%d,%d,%d,%d,%d\n",wan,qian,bai,shi,ge);
printf("%d%d%d%d%d\n",ge,shi,bai,qian,wan) ;
}
else if(num>999)
{
place=4;
printf("%d\n",place);
printf("%d,%d,%d,%d\n",qian,bai,shi,ge);
printf("%d%d%d%d\n",ge,shi,bai,qian);
}
else if(num>99)
{
place=3;
printf("%d\n",place);
printf("%d,%d,%d\n",bai,shi,ge);
printf("%d%d%d\n",ge,shi,bai);
}
else if(num>9)
{
place=2;
printf("%d\n",place);
printf("%d,%d\n",shi,ge);
printf("%d%d%\n",ge,shi);
}
else
{
place=1;
printf("%d\n",place);
printf("%d\n",ge);
printf("%d\n",ge);
}
...