亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么編譯沒有報錯,但一運行就錯誤。。

為什么編譯沒有報錯,但一運行就錯誤。。

C
番茄的卍番茄醬 2016-08-21 16:52:09
#include<stdio.h>#include<string.h>#include<stdlib.h>struct time{?int hour;?int minute;?int second;};struct time TimeUpdate(struct time now);int main(int argc,char const argv[]){?int i;?struct time testtimes[5]={{23,59,59},{12,52,36},{06,12,58},{00,00,00},{25,01,26}};?for(i=0;i<5;i++)?{?printf("Time is %02d:%02d:%02d\n",testtimes[i].hour ,testtimes[i].minute ,testtimes[i].second );?testtimes[i]=TimeUpdate(testtimes[i]);?printf("...one second after the now time is %02d:%02d:%02d\n",testtimes[i].hour ,testtimes[i].minute ,testtimes[i].second);?getchar(); ?}?return 0;}struct time TimeUpdate(struct time now){?if(now.hour>=0&&now.hour<24)?{??if(now.second>=60)??{???now.minute=now.minute +now.second /60;???now.second=now.second-60*(now.second/60);??????? if(now.minute>=60)???? {???? now.hour=now.hour+now.minute/60;???? now.minute=now.minute-60*(now.minute/60);???? }??}??printf("您輸入的標準時間格式是 %02d:%02d:%02d\n",now.hour,now.minute ,now.second );??++now.second;??if(now.second ==60)??{???now.second=0;???++now.minute;???if(now.minute==60)???{????now.minute=0;????++now.hour;????if(now.hour==24)????{?????now.hour =0;????}???}??}????}?else?{??printf("時間輸入有誤!\n");?}}
查看完整描述

2 回答

已采納
?
阿旭_

TA貢獻217條經驗 獲得超353個贊

錯誤的提示是什么?

我試著運行了一下,可以運行,結果如下:

http://img1.sycdn.imooc.com//57b973640001f55504880263.jpg

查看完整回答
1 反對 回復 2016-08-21
  • 番茄的卍番茄醬
    番茄的卍番茄醬
    可是我要的明顯不是這個意思。。。
  • 阿旭_
    阿旭_
    你要的最終輸出結果是什么樣的?這樣其它人也好明白你的程序意圖并加以改正
  • 番茄的卍番茄醬
    番茄的卍番茄醬 回復 阿旭_
    我知道哪里,出錯了,應該最下面那個函數里添加一個 return now;就OK啦!謝啦
點擊展開后面1
?
番茄的卍番茄醬

TA貢獻5條經驗 獲得超1個贊

添加一個retern now;

查看完整回答
反對 回復 2016-08-26
  • 2 回答
  • 0 關注
  • 1559 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號