close
題目:輸入100~999的數字,將每一個數字拆開來並做加、減、乘的計算,將結果顯示畫面上。例: 984 加:9+8+4=21
int intMath = 548;
// 將個位數、十位數、百位數拆開來
int a = intMath / 100;
int b = (intMath - (a * 100)) / 10;
int c = (intMath - (a * 100) - (b * 10));
int aa = a + b + c;
int bb = a - b - c;
int cc = a * b * c;
Label1.Text = "加 = " + aa;
Label2.Text = "減 = " + bb;
Label3.Text = "乘 = " + cc;
全站熱搜
留言列表