看板 NTUEE107HW 關於我們 聯絡資訊
#include <iostream> #include <stdio.h> using std::cin; using std::cout; using std::endl; int main() { int a,b,c,Large,Small; cout << "Please type in 3 different numbers\n"; cin >> a >> b >> c; Large=b; Small=a; if (a>b) Large=a; Small=b; if (c<Small) Small=c; if (c>Large) Large=c; cout << "Sum is " << a+b+c << endl; cout << "Mean = " << (a+b+c)/3 << endl; cout << "Product is " << a*b*c << endl; cout << "Largest is " << Large << endl; cout << "Smallest is " << Small << endl; system ("PAUSE"); return 0; } 你們試著輸入3;5;4 結果會變得很奇怪 smallest會是4 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.167.160.47