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

為了賬號安全,請及時綁定郵箱和手機立即綁定

我的代碼是根據新的題目的,同學代碼貌似都是舊題目的答案。我的有點復雜而且只能在idea里跑,請大家看看什么問題。

import?java.util.Scanner;

public?class?Demo3?{


????public?static?void?main(String[]?args)?{
????????//創建String數組,并為每一個元素賦值。賦值內容為第幾周+學習內容
????????String[]?contentList?=?new?String[35];
????????contentList[0]?=?"【第1周】環境搭建與語法入門";
????????contentList[1]?=?"【第2周】Java語法之循環、數組與方法";
????????contentList[2]?=?"【第3周】面向對象之封裝與繼承";
????????contentList[3]?=?"【第4周】面向對象之單例模式與多態";
????????contentList[4]?=?"【第5周】常用工具類(上)";
????????contentList[5]?=?"【第6周】常用工具類(中)";
????????contentList[6]?=?"【第7周】常用工具類(下)";
????????contentList[7]?=?"【第8周】前端基礎之HTML與CSS";
????????contentList[8]?=?"【第9周】前端基礎之JavaScript與綜合案例";
????????contentList[9]?=?"【第10周】Java?Web基礎";
????????contentList[10]?=?"【第11周】Java?Web基礎";
????????contentList[11]?=?"【第12周】常用功能與過濾器";
????????contentList[12]?=?"【第13周】監聽器與項目實戰";
????????contentList[13]?=?"【第14周】監聽器與項目實戰";
????????contentList[14]?=?"【第15周】MySQL基礎";
????????contentList[15]?=?"【第16周】MySQL基礎";
????????contentList[16]?=?"【第17周】Java數據庫開發基礎";
????????contentList[17]?=?"【第18周】框架前置知識";
????????contentList[18]?=?"【第19周】MyBatis基礎";
????????contentList[19]?=?"【第20周】MyBatis實現OA系統項目實戰";
????????contentList[20]?=?"【第21周】MyBatis實現OA系統項目實戰";
????????contentList[21]?=?"【第22周】Linux環境搭建與Redis應用";
????????contentList[22]?=?"【第23周】Spring基礎";
????????contentList[23]?=?"【第24周】Spring基礎";
????????contentList[24]?=?"【第25周】Spring基礎";
????????contentList[25]?=?"【第26周】SSM開發社交網站";
????????contentList[26]?=?"【第27周】Spring?Boot電商項目實戰";
????????contentList[27]?=?"【第28周】Spring?Boot電商項目實戰";
????????contentList[28]?=?"【第29周】面試";
????????contentList[29]?=?"【第30周】多線程與分布式";
????????contentList[30]?=?"【第31周】多線程與分布式";
????????contentList[31]?=?"【第32周】Spring?Cloud基礎";
????????contentList[32]?=?"【第33周】Spring?Cloud電商實戰";
????????contentList[33]?=?"【第34周】Spring?Cloud電商實戰";
????????contentList[34]?=?"【第35周】Zookeeper+Dubbo應用與面試";

????????//提示信息
????????System.out.print("您要開始第幾周學習啦,直接輸入數字吧(0~35):");
????????//設置變量存儲接收到的數據
????????int?weeks??=?new?Scanner(System.in).nextInt();

????????//計算今天是幾月(1-月第一周、4-月第4周)
????????int?month?=?(weeks/4)+1;

????????//計算輸入的周是這個月的第幾周
????????int?week?=?weeks%4;
????????//提示信息
????????System.out.println("以下是您本月的學習計劃,?√?代表當周學習任務");
????????System.out.println("=======================================");
????????if(weeks<=35)?{
????????????if?(week?!=?0)?{
????????????????//利用for循環,找到數組中對應這個月的內容輸出
????????????????for?(int?i?=?weeks?-?week?+?1;?i?<=?weeks?-?week?+?4;?i++)?{
????????????????????if?(weeks?!=?i)?{
????????????????????????System.out.println(contentList[(i?-?1)]);
????????????????????}?else
????????????????????????System.out.println("√"?+?contentList[(weeks?-?1)]);
????????????????}
????????????????//根據當前月第幾周,在輸出此行時,前面添加“√”
????????????}?else?{
????????????????for?(int?i?=?weeks?-?3;?i?<=?weeks;?i++)?{
????????????????????if?(weeks?!=?i)?{
????????????????????????System.out.println(contentList[(i?-?1)]);
????????????????????}?else
????????????????????????System.out.println("√"?+?contentList[(weeks?-?1)]);
????????????????}
????????????}
????????}
????????else{
????????????System.out.println("學了那么久已經成仙了");
????????}
????}
}


正在回答

7 回答

import?java.sql.SQLOutput;
import?java.util.Scanner;

public?class?HelloWorld?{
????public?static?void?main(String[]?args)?{
????????String[]?contentList?=?new?String[35];
????????contentList[0]?=?"【第1周】環境搭建與語法入門";
????????contentList[1]?=?"【第2周】Java語法之循環、數組與方法";
????????contentList[2]?=?"【第3周】面向對象之封裝與繼承";
????????contentList[3]?=?"【第4周】面向對象之單例模式與多態";
????????contentList[4]?=?"【第5周】常用工具類(上)";
????????contentList[5]?=?"【第6周】常用工具類(下)";
????????contentList[6]?=?"【第7周】常用工具類(下)";
????????contentList[7]?=?"【第8周】前端基礎之HTML與CSS";
????????contentList[8]?=?"【第9周】前端基礎之JavaScript與綜合案例";
????????contentList[9]?=?"【第10周】Java?Web基礎";
????????contentList[10]?=?"【第11周】Java?Web基礎";
????????contentList[11]?=?"【第12周】常用功能與過濾器";
????????contentList[12]?=?"【第13周】監聽器與項目實戰";
????????contentList[13]?=?"【第14周】監聽器與項目實戰";
????????contentList[14]?=?"【第15周】MySQL基礎";
????????contentList[15]?=?"【第16周】MySQL基礎";
????????contentList[16]?=?"【第17周】Java數據庫開發基礎";
????????contentList[17]?=?"【第18周】框架前置知識";
????????contentList[18]?=?"【第19周】MyBatis基礎";
????????contentList[19]?=?"【第20周】MyBatis實現OA系統項目實戰";
????????contentList[20]?=?"【第21周】MyBatis實現OA系統項目實戰";
????????contentList[21]?=?"【第22周】Linux環境搭建與Redis應用";
????????contentList[22]?=?"【第23周】Spring基礎";
????????contentList[23]?=?"【第24周】Spring基礎";
????????contentList[24]?=?"【第25周】Spring基礎";
????????contentList[25]?=?"【第26周】SSM開發社交網站";
????????contentList[26]?=?"【第27周】Spring?Boot電商項目實戰";
????????contentList[27]?=?"【第28周】Spring?Boot電商項目實戰";
????????contentList[28]?=?"【第29周】面試";
????????contentList[29]?=?"【第30周】多線程與分布式";
????????contentList[30]?=?"【第31周】多線程與分布式";
????????contentList[31]?=?"【第32周】Spring?Cloud基礎";
????????contentList[32]?=?"【第33周】Spring?Cloud電商實戰";
????????contentList[33]?=?"【第34周】Spring?Cloud電商實戰";
????????contentList[34]?=?"【第35周】Zookeeper+Dubbo應用與面試";

????????//提示信息
????????System.out.print("您要開始第幾周學習啦,直接輸入數字吧:");
????????//設置變量存儲接收到的數據
????????int???weeks=?new?Scanner(System.in).nextInt();
????????int??month,week;
????????//計算今天是幾月(1-月第一周、4-月第4周)
????????if(weeks%4==0)
?????????{?month=weeks/4;
???????????week=4;}
????????else
?????????????{month=weeks/4+1;
????????//計算輸入的周是這個月的第幾周
????????week=weeks%4;}
????????//提示信息
????????System.out.println("以下是5您本月的學習計劃,?√?代表當周學習任務");
????????System.out.println("=======================================");

????????//利用for循環,找到數組中對應這個月的內容輸出
????????int?j=0;
????????//根據當前月第幾周,在輸出此行時,前面5添加“√”
????????for(int?i=(month-1)*4;i<month*4;i++)
????????{???j++;
????????????if(j==week)
????????????????System.out.println("√"+contentList[i]);
????????????else
????????????????System.out.println(contentList[i]);
????????}

????}
}


0 回復 有任何疑惑可以回復我~

你的代碼,輸入第8周,就出問題了,會變成第三個月

0 回復 有任何疑惑可以回復我~

你看看我的,可能會簡單一些,

public?static?void?main(String[]?args)?{
????//創建String數組,并為每一個元素賦值。賦值內容為第幾周+學習內容
????String[]?contentList?=?new?String[35];
????contentList[0]?=?"【第1周】環境搭建與語法入門";
????contentList[1]?=?"【第2周】Java語法之循環、數組與方法";
????contentList[2]?=?"【第3周】面向對象之封裝與繼承";
????contentList[3]?=?"【第4周】面向對象之單例模式與多態";

????contentList[4]?=?"【第5周】常用工具類(上)";
????contentList[5]?=?"【第6周】常用工具類(下)";
????contentList[6]?=?"【第7周】常用工具類(下)";
????contentList[7]?=?"【第8周】前端基礎之HTML與CSS";

????contentList[8]?=?"【第9周】前端基礎之JavaScript與綜合案例";
????contentList[9]?=?"【第10周】Java?Web基礎";
????contentList[10]?=?"【第11周】Java?Web基礎";
????contentList[11]?=?"【第12周】常用功能與過濾器";

????contentList[12]?=?"【第13周】監聽器與項目實戰";
????contentList[13]?=?"【第14周】監聽器與項目實戰";
????contentList[14]?=?"【第15周】MySQL基礎";
????contentList[15]?=?"【第16周】MySQL基礎";

????contentList[16]?=?"【第17周】Java數據庫開發基礎";
????contentList[17]?=?"【第18周】框架前置知識";
????contentList[18]?=?"【第19周】MyBatis基礎";
????contentList[19]?=?"【第20周】MyBatis實現OA系統項目實戰";

????contentList[20]?=?"【第21周】MyBatis實現OA系統項目實戰";
????contentList[21]?=?"【第22周】Linux環境搭建與Redis應用";
????contentList[22]?=?"【第23周】Spring基礎";
????contentList[23]?=?"【第24周】Spring基礎";

????contentList[24]?=?"【第25周】Spring基礎";
????contentList[25]?=?"【第26周】SSM開發社交網站";
????contentList[26]?=?"【第27周】Spring?Boot電商項目實戰";
????contentList[27]?=?"【第28周】Spring?Boot電商項目實戰";

????contentList[28]?=?"【第29周】面試";
????contentList[29]?=?"【第30周】多線程與分布式";
????contentList[30]?=?"【第31周】多線程與分布式";
????contentList[31]?=?"【第32周】Spring?Cloud基礎";

????contentList[32]?=?"【第33周】Spring?Cloud電商實戰";
????contentList[33]?=?"【第34周】Spring?Cloud電商實戰";
????contentList[34]?=?"【第35周】Zookeeper+Dubbo應用與面試";

????//提示信息
????System.out.print("您要開始第幾周學習啦,直接輸入數字吧:");
????//設置變量存儲接收到的數據
????int?a??=?new?Scanner(System.in).nextInt();

????//計算今天是幾月(1-月第一周、4-月第4周)
????int?month?=?a?/?4?;
????if?(a?%?4?!=?0?){
????????month?=?month?+?1;
????}
????System.out.println("這周屬于"?+?month?+?"月!");
????//計算輸入的周是這個月的第幾周
????int?week?=?a?%?4;
????if(week==0){
????????week?=?4;
????}
????System.out.println("這周屬于"+?month?+?"月的,第"?+?week?+?"周!");
????//提示信息
????System.out.println("以下是您本月的學習計劃,?√?代表當周學習任務");
????System.out.println("=======================================");
????//利用for循環,找到數組中對應這個月的內容輸出
????//根據當前月第幾周,在輸出此行時,前面添加“√”
????for(int?i?=?a?-?week?;i<=?a?-?week?+?3;i++){
????????if?(i?+?1?==?a?){
????????????System.out.println("√"?+?contentList[i]);
????????}else{
????????????System.out.println(contentList[i]);
????????}
????}
}



2 回復 有任何疑惑可以回復我~

雖然寫代碼需要想象力,但是你這個代碼 在算法上根本就不能通過,畢竟老師講的這個確實比你的簡單的多,明明一個if else,一個for循環可以解決的問題,非要搞兩個for循環,開始的時候? 輸入0-35也沒什么問題,但是就感覺 畫蛇添足,老師講的是思路,讓你會運用這些,而不是非要讓你按照老師的方法來,你有更簡單的你也可以寫

0 回復 有任何疑惑可以回復我~
select?*?from?tbl;


0 回復 有任何疑惑可以回復我~

你寫的代碼真復雜,我覺得你是個弟弟了。

0 回復 有任何疑惑可以回復我~

應該沒有什么問題吧

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

我的代碼是根據新的題目的,同學代碼貌似都是舊題目的答案。我的有點復雜而且只能在idea里跑,請大家看看什么問題。

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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