第四周作業

2022-05-28 22:15:17 字數 1445 閱讀 5879

1.編寫程式, 輸入變數x的值,如果是1,輸出x=1,如果是5,輸出x=5,如果是 10,輸出 x=10,除了以上幾個值,都輸出x=none。(知識點:if條件語句)

package

public

class

play

else

}public

static

void

main(string args)

}

2.用switch結構實現第1題

package

public

class

play

}public

static

void

main(string args)

}

3.判斷乙個數字是否能被5和6同時整除(列印能被5和6整除),或只能被5整除(列印能被5整 除),或只能被6整除,(列印能被6整除),不能被5或6整除,(列印不能被5或6整除)

package

public

class

play

else

if((num%5 == 0) && (num%6 != 0))

else

if((num%5 != 0) && (num%6 == 0))

else

}public

static

void

main(string args)

}

4.輸入乙個0~100的分數,如果不是0~100之間,列印分數無效,根據分數等級列印 a(90-100),b(80-89),c,d,e(知識點:條件語句if elseif)

package

public

class

play

else}}

public

static

void

main(string args)

}

5.輸入三個整數x,y,z,請把這三個數由小到大輸出(知識點:條件語句)

package

public

class

play

else

if (num_x < num_y && num_y else

if (num_x > num_y && num_y < num_z && num_x >num_z)

else

if(num_x > num_y && num_y < num_z && num_x else

if(num_x < num_z && num_x < num_y && num_z >num_y)

else

}public

static

void

main(string args)

}

第四周作業

第四周實驗作業 1.完成課本每乙個程式設計題。要求先畫出流程演算法圖或n s圖,然後程式設計實現,有可能的話使用兩種以上方法 1.1求自然對數e的近似值 include using namespace std int main cout 1.2求圓周率 的近似值 include using name...

第四周作業

實驗作業1.完成課本每乙個程式設計題。要求先畫出流程演算法圖或n s圖,然後程式設計實現,有可能的話使用兩種以上方法 2.程式設計求 百錢百雞 問題。雞翁一值錢五,雞母 一值錢三,雞雛三值錢一。百錢買百雞,問雞翁 雞母 雞雛各幾何?3.程式設計輸入乙個整數,計算它是幾位數字,分別輸出每一位數字,並輸...

第四周作業

實驗作業1.完成課本每乙個程式設計題。要求先畫出流程演算法圖或n s圖,然後程式設計實現,有可能的話使用兩種以上方法 2.程式設計求 百錢百雞 問題。雞翁一值錢五,雞母 一值錢三,雞雛三值錢一。百錢買百雞,問雞翁 雞母 雞雛各幾何?3.程式設計輸入乙個整數,計算它是幾位數字,分別輸出每一位數字,並輸...