roberthsu2003 / cAndC-

48 stars 18 forks source link

作業2: #13

Closed roberthsu2003 closed 9 months ago

roberthsu2003 commented 10 months ago

讓使用者輸入三個任意數,程式會顯示三數中的最小數。

XOYouLinOX commented 10 months ago
#include <iostream>
using namespace std;
int main() {
  double in1 , in2,in3, max;
  cout <<"輸入第1個數:";
  cin >> in1;

  cout <<"輸入第2個數:";
  cin >> in2;

  max = in1 > in2 ? in2 : in1 ;

  cout <<"輸入第3個數:";
  cin >> in3;

  max = in3 > max ? max : in3 ;

  cout << "輸入3個數中最小的數為:" << max << "\n";
}
lan0223333 commented 10 months ago
#include <iostream>
//讓使用者輸入三任意數,程式會顯示最小的數
using namespace std;
int main() {
  double in1, in2, in3, min;
  cout << "輸入第一個數";
  cin >> in1;

  cout << "輸入第二個數";
  cin >> in2;
  min = in1 < in2 ? in1 : in2;

  cout << "輸入第三個數";
  cin >> in3;
  min = in3 < min ? in3 : min;

  cout << "最小數為:" << min << "\n";
  return 0;
}``
qwezxciop46 commented 10 months ago
#include <iostream>
//讓使用者輸入三個任意數,程式會顯示三數中的最小數。
using namespace std;
int main() {
  double in1,in2,in3,max;
  cout << "請輸入第1個數:";
  cin >> in1;

  cout << "請輸入第2個數:";
  cin >> in2;

  max = in1 < in2 ? in1 : in2;

  cout << "請輸入第3個數:";
  cin >> in3;

  max = in3 < max ? in3 : max;

  cout << "輸入3個數中最大小的數為:" << max << "\n";

  return 0;
}
Ray07046666 commented 10 months ago

include

using namespace std; int main() { double in1,in2,in3,min; cout << "請輸入第1個數:"; cin >> in1;

cout << "請輸入第2個數:"; cin >> in2;

min = in1 < in2 ? in1 : in2;

cout << "請輸入第3個數:"; cin >> in3;

min= in3 <min ? in3 : min;

cout << "輸入3個數中最小的數為:" << min << "\n";

return 0; }

Rickylo0918 commented 10 months ago

include

using namespace std;

int main() {
  double a, b, c, min;
  cout << "請輸入第一個數" << endl;
  cin >> a;
  cout << "請輸入第二個數" << endl;
  cin >> b;
  cout << "請輸入第三個數" << endl;
  cin >> c;
  min = (a < b) ? (a < c ? a : c) : (b < c ? b : c);
  cout << "最小數為" << min << endl;

  return 0;
}
alvin951020 commented 10 months ago
#include <iostream>
using namespace std;

int main() {
  double in1;
  double in2;
  double in3;
  double min;

  cout<<"請輸入第1個數:";
  cin>>in1;
  cout<<"請輸入第2個數:";
  cin>>in2;
  cout<<"請輸入第3個數:";
  cin>>in3;
  min=in1<in2?in1:in2;
  min=min<in3?min:in3;

  cout<<"最小數為:"<<min<<"\n";
}
ChiuKuanHsun commented 10 months ago
#include <iostream>
using namespace std;
int comparexyz(int x, int y, int z) {
  if (x > y && x > z) {
    return x;}
   else if (y > x && y >z)
   {return y;}
  else{
    return z;
  }
}
int main() {
  int x,y,z;
  cout<<"請隨意輸入三個整數:";
  cin>>x>>y>>z;
  int result=comparexyz(x,y,z);
  cout<<"最大值為:"<<result<<endl;
}