課程
/后端開發(fā)
/C
/C語言入門
用這種代碼的好處在哪里?
2017-09-27
源自:C語言入門 4-16
正在回答
沒缺什么
#include<stdio.h>int main(){?int year=2008;?int month=8;?int day=8;?int a;?int b;?int c;?int d;?a=year%4;?b=1??if(month>2)?{???? if(month-5.5==0.5||3.5||4.5)????? {for(b;b<=12-month;b++)?? {if(b%2!=0)???? {result=result+31;???? }???? else???? {result=result+30;???? }????? }????? c=366-result+day;????? printf("現(xiàn)在已經(jīng)過了%d天了",c);????? }????? ?? ???? else if(month==9) ????? {for(b;b<=12-month;b++)?? {if(b%2!=0)???? {result=result+31;???? }???? else???? {result=result+30;???? }??? c=366-result+day; ????? }????? printf("現(xiàn)在已經(jīng)過了%d天了",c);????? }? ???? else if(month=11) ????? {for(b;b<=12-month;b++)?? {if(b%2!=0)???? {result=result+31;???? }???? else???? {result=result+30;???? }??? c=366-result+day; ????? }????? printf("現(xiàn)在已經(jīng)過了%d天了",c);????? }???? else if(month=4)????? {result=(12-month+2)/2*31+(12-month-2)/2*30;?????? c=366-result+day;?????? printf("現(xiàn)在已經(jīng)過了%d天了",c);????? }???? else if(month=6)????? {result=(12-month+2)/2*31+(12-month-2)/2*30;?????? c=366-result+day;?????? printf("現(xiàn)在已經(jīng)過了%d天了",c);????? }??????? else i????? {if(month=1)??????? {result=31;????? printf("現(xiàn)在已經(jīng)過了%d天了",result);??}???? else???? {result=31+29;????? printf"現(xiàn)在已經(jīng)過了%d天了",result);??}?? } ??? }?? ??
還有一個問題要請教大家,這個是我自己在DEV C++上寫的,但是編譯時一直顯示else if(month==9)錯誤,如果就單單從語句的使用來看,請大家?guī)兔Ω嬖V我是哪里錯了,謝謝
忘記傳了,抱歉
代碼呢?
RUNOOB_XIE 提問者
舉報
C語言入門視頻教程,帶你進(jìn)入編程世界的必修課-C語言
1 回答求解求解求解
3 回答求解求解求解
4 回答求解求解求解
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-09-28
沒缺什么
2017-09-27
#include<stdio.h>
int main()
{
?int year=2008;
?int month=8;
?int day=8;
?int a;
?int b;
?int c;
?int d;
?a=year%4;
?b=1
?
?if(month>2)
?{
???? if(month-5.5==0.5||3.5||4.5)
????? {for(b;b<=12-month;b++)
?? {if(b%2!=0)
???? {result=result+31;
???? }
???? else
???? {result=result+30;
???? }
????? }
????? c=366-result+day;
????? printf("現(xiàn)在已經(jīng)過了%d天了",c);
????? }
?????
??
???? else if(month==9)
????? {for(b;b<=12-month;b++)
?? {if(b%2!=0)
???? {result=result+31;
???? }
???? else
???? {result=result+30;
???? }
??? c=366-result+day;
????? }
????? printf("現(xiàn)在已經(jīng)過了%d天了",c);
????? }?
???? else if(month=11)
????? {for(b;b<=12-month;b++)
?? {if(b%2!=0)
???? {result=result+31;
???? }
???? else
???? {result=result+30;
???? }
??? c=366-result+day;
????? }
????? printf("現(xiàn)在已經(jīng)過了%d天了",c);
????? }
???? else if(month=4)
????? {result=(12-month+2)/2*31+(12-month-2)/2*30;
?????? c=366-result+day;
?????? printf("現(xiàn)在已經(jīng)過了%d天了",c);
????? }
???? else if(month=6)
????? {result=(12-month+2)/2*31+(12-month-2)/2*30;
?????? c=366-result+day;
?????? printf("現(xiàn)在已經(jīng)過了%d天了",c);
????? }
??????? else i
????? {if(month=1)
??????? {result=31;
????? printf("現(xiàn)在已經(jīng)過了%d天了",result);
??}
???? else
???? {result=31+29;
????? printf"現(xiàn)在已經(jīng)過了%d天了",result);
??}
?? }
??? }??
??
還有一個問題要請教大家,這個是我自己在DEV C++上寫的,但是編譯時一直顯示else if(month==9)錯誤,如果就單單從語句的使用來看,請大家?guī)兔Ω嬖V我是哪里錯了,謝謝
2017-09-27
2017-09-27
代碼呢?