C 語言if迴圈練習

2022-05-18 22:50:24 字數 2566 閱讀 6722

namespace c語言2

else

else if (b > 0 && b < 10)

else if (b > 0 && b < 60)

else if (b >= 60)

else if (b >= 90)

//手勢

console.write("請輸入您的手勢(石頭/剪子/包袱):");

string c = convert.tostring(console.readline());

console.write("請輸入電腦的手勢(石頭/剪子/包袱):");

string d = convert.tostring(console.readline());

if (c == "石頭" && d == "石頭")

else if (c == "石頭" && d == "剪子")

else if (c == "石頭" && d == "包袱")

else if (c == "剪子" && d == "剪子")

else if (c == "剪子" && d == "石頭")

else if (c == "剪子" && d == "包袱")

else if (c == "包袱" && d == "包袱")

else if (c == "包袱" && d == "剪子")

else if (c == "包袱" && d == "石頭")

console.readline();

console.write("請輸入對話:");

string d = convert.tostring(console.readline());

console.write("請輸入電腦對話:");

string e = convert.tostring(console.readline());

if (d == "你好" && e == "你好")

else if (d == "你好" && e == "你也很好")

console.readline();

// 判斷年份

console.write("請輸入年份:");

int year = convert.toint32(console.readline());

if (year <= 0 || year > 9999)

else

else

else if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && (day > 0 && day <= 31))

else if ((month == 4 || month == 6 || month == 9 || month == 11) && (day > 0 && day <= 30))

else if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)

else

}else if (month == 2 && (day > 0 && day < 29))

else

console.readline();}}

console.writeline("標準體重");

console.writeline("男士體重(kg)=身高(cm)-100+-3");

console.writeline("女士體重(kg)=身高(cm)-110+-3");

console.write("請輸入您的性別:");

string xb = console.readline();

console.write("請輸入您的身高:");

int height = convert.toint32(console.readline());

console.write("請輸入您的體重:");

int weight = convert.toint32(console.readline());

if (xb == "男")

else

}else

else

}int m1 = 31, m2 = 28, m3 = 31, m4 = 30, m5 = 31, m6 = 30, m7 = 31, m8 = 31, m9 = 30, m10 = 31, m11 = 30;

console.writeline("請輸入月份");

int m = int.parse(console.readline());

console.writeline("請輸幾號");

int d = int.parse(console.readline());

switch (m)

console.write("請輸入24小時制的時間0-24:");

int time = convert.toint32(console.readline());

if (time >= 0 && time <= 24)

else if (time > 6 && time <= 12)

else if (time > 12 && time <= 22)}}

C語言中的迴圈語句練習

注 練習題目均出自 明解c語言 入門篇 1,求多個整數的和及平均值 includeint main void while retry 0 printf 和為 d,平均值為 2f。n 1,遞增顯示從0到輸入的正整數為止的各個整數 2,編寫一段程式,按照公升序顯示出小於輸入值的所有正偶數 include...

C語言中迴圈語句練習例項

計算n的階乘 int main printf d n ret return 0 計算int main sum ret printf d n sum return 0 演算法效率低 效率高的方法 int main printf d n sum reurn 0 在乙個有序陣列中查詢具體的某個數字n 折半...

C語言的迴圈小練習詳解

目錄 int main printf d ret return 0 int main printf d sum return 例如tqqdsaor i love china 和 每次左邊右邊乙個 變成第一行,如下 include include int main return 0 程式執行結果 上述...