当前位置: 代码迷 >> C语言 >> [求助]帮忙看看这个程序有什么问题
  详细解决方案

[求助]帮忙看看这个程序有什么问题

热度:59   发布时间:2007-01-15 17:24:07.0
[求助]帮忙看看这个程序有什么问题

输入某天的时,分,秒,输出下一时刻的时,分,秒。
#include "stdio.h"
main()
{int h,m,s;
printf("Enter the time:\n");
scanf("%d,%d,%d",h,m,s);

if(s<59) s=s+1;
printf("Now the time is:%d,%d,%d\n",h,m,s);
else if(s=59)
{
if(m<59) {m=m+1;s=0;}
printf("Now the time is:%d,%d,%d\n",h,m,s);
else if(m=59&&h<23) {h=h+1;m=0;s=0;}
printf("Now the time is:%d,%d,%d\n",h,m,s);
else if(m=59&&h=23) {h=0;m=0;s=0;}
printf("Now the time is:%d,%d,%d\n",h,m,s);

}


}

为什么这段代码不能运行,麻烦高手帮忙解决下。


搜索更多相关的解决方案: include  Enter  

----------------解决方案--------------------------------------------------------

什么叫: 输入某天的时,分,秒,输出下一时刻的时,分,秒。


----------------解决方案--------------------------------------------------------
刚才把书看了下,弄明白了,谢谢
----------------解决方案--------------------------------------------------------

我看了你的代码,然后修改一下,增加了对时间输入错误的限制。
运行起来觉得还好,如果有发现 什么问题一起讨论。
/* Note:Your choice is C IDE */
#include "stdio.h"
main()
{
int h,m,s;
printf("Enter the time:\n");
scanf("%d%d%d",&h,&m,&s);
while(h>=24||m>=60||s>=60)
{
printf("Your input numbers are wrong!\n");
printf("Please input the right number:\n");
printf("Enter the time:\n");
scanf("%d%d%d",&h,&m,&s);
}

if(s<59)
{s=s+1;
printf("Now the time is:%d %d %d\n",h,m,s);
}
else
{
if(m<59)
{m=m+1;s=0;
printf("Now the time is:%d %d %d\n",h,m,s);
}
else if(m=59&&h<23)
{h=h+1;m=0;s=0;
printf("Now the time is:%d %d %d\n",h,m,s);
}
else
{h=0;m=0;s=0;
printf("Now the time is:%d %d %d\n",h,m,s);
}

}


}


----------------解决方案--------------------------------------------------------
谢谢楼上的朋友
----------------解决方案--------------------------------------------------------

就这?
----------------解决方案--------------------------------------------------------

----------------解决方案--------------------------------------------------------
我也不太清楚这个题目,

----------------解决方案--------------------------------------------------------

冰封怎么跑这来了?去水区


----------------解决方案--------------------------------------------------------
  相关解决方案