| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 461 人关注过本帖
标题:又有问题了~~帮忙
只看楼主 加入收藏
lovebambo
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-9-17
收藏
 问题点数:0 回复次数:3 
又有问题了~~帮忙
#include "stdio.h"

struct time
{
    int hour;
    int minutes;
    int seconds;
};

int main( void )
{
    struct time timeupdate ( struct time now );
    struct currenttime,nexttime;
   
    printf ("enter the time ( hh: mm: ss )");
    scanf ("%i:%i:%i", &currenttime.hour, &currenttime.minutes, &currenttime.seconds );
   
    nexttime = timeupdate (currenttime);
    printf ("updated time is %.2i:%.2i:%.2i\n",nexttime.hour, nexttime.minutes, nexttime.seconds);
   
    return 0;
}

struct time timeupdate ( struct time now )
{
    
    ++now.seconds;
    if ( seconds == 60 ) {
        now.seconds = 0;
        ++now.minutes;
    
    if ( minutes == 60) {
        now.minutes = 0;
        ++now.hour;
        
        if ( now.hour == 24 ) {
            now.hour = 0;
        }
    }
    return now;
}
2008-09-18 17:22
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:0 
= =难道你自己不会调试么?自己动手吧,否则永远学不会东西的。

专心编程………
飞燕算法初级群:3996098
我的Blog
2008-09-18 17:39
葬烟
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2008-9-3
收藏
得分:0 
改过了:
#include <stdio.h>

struct time
{
    int hour;
    int minutes;
    int seconds;
}time;

struct time timeupdate ( struct time nows )
{
   
    ++nows.seconds;
    if ( nows.seconds == 60 )
    {
          nows.seconds = 0;
          ++nows.minutes;
    }
   
    if ( nows.minutes == 60)
    {
        nows.minutes = 0;
        ++nows.hour;
        }
        if ( nows.hour == 24 )
    {
            nows.hour = 0;
        }
    return nows;
}

int main()
{
    //struct time timeupdate ( struct time now );
    struct time currenttime;
    struct time nexttime;
    printf ("enter the time ( hh: mm: ss )\n");
    scanf ("%i:%i:%i", &currenttime.hour, &currenttime.minutes, &currenttime.seconds );
    nexttime = timeupdate (currenttime);
    printf ("updated time is %.2i:%.2i:%.2i\n",nexttime.hour, nexttime.minutes, nexttime.seconds);
    return 0;
}

  那些括号阿,小算法阿以后自己多注意点就行了。
2008-09-18 21:10
lovebambo
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-9-17
收藏
得分:0 
同学太感谢你了~~我也不知道怎么回事,看了三遍就是看不出区别,太初心了
2008-09-19 08:22
快速回复:又有问题了~~帮忙
数据加载中...
 
   



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

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