| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1845 人关注过本帖
标题:求助!請C語言高手幫我看看這個錯在哪裡~
取消只看楼主 加入收藏
qynn
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-10-8
收藏
 问题点数:0 回复次数:1 
求助!請C語言高手幫我看看這個錯在哪裡~
題目:
輸入一個不多於5位的正整數,要求:
1.求它是幾位數;
2.分別輸出每一位數字;
3.按照逆序輸出各位數字。例如原數位321,應輸出123.



我的編程如下:
#include<stdio.h>
#include<math.h>

void main()
{
long int number;
int indiv,ten,hund,thou,t_th; /*分别代表个位、十位、百位、千位、万位*/
printf("place input a whole number(0~99999):\n");
scanf("%ld",&number);

if(number<0||number>99999)printf(“The date is error\n");
else if(number>9999)printf("place=5");
else if(number>999)printf("place=4");
else if(number>99)printf("place=3");
else if(number>9)printf("place=2");
else printf("place=1");
printf("each number is:");
t-th=number/10000;
thou=(int)(number-t_th*10000)/1000;
hund=(int)(nnumber-t_th*10000-thou*1000)/100;
ten=(int)(number-t_th*10000-thou*1000-hund*100)/10;
indiv=(int)(number-t_th*10000-thou*1000-hund*100-ten*10);

{
if(number>9999)printf("%d,%d,%d,%d,%d",t_th,thou,hund,ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d%d%d%d\n",indiv,ten,hund,thou,t_th);

else if(number>999)printf("%d,%d,%d,%d",thou,hund,ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d%d%d\n",indiv,ten,hund,thou);

else if(number>99)printf("%d,%d,%d",hund,ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d%d\n",indiv,ten,hund);

else if(number>9)printf("%d,%d",ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d\n",indiv,ten);

else printf("%d",indiv);
printf("\nThe reverse number is:");
printf("%d\n",indiv);
}
}




点击运行的时候上面程序红色部分代码总是显示misplaced else in function main
但是我又不知道ELSE的位置哪里错了。
 
我是新学者,对C语言仍旧十分生涩。
请高手给予指点。

谢谢。

[[it] 本帖最后由 qynn 于 2008-10-8 12:49 编辑 [/it]]
搜索更多相关主题的帖子: C语言 
2008-10-08 12:44
qynn
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-10-8
收藏
得分:0 
谢谢楼上的朋友。
现在这个程序会了。呵呵
2008-10-09 08:19
快速回复:求助!請C語言高手幫我看看這個錯在哪裡~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023870 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved