C 程式找出三個數中最大的數
此程式獲取 3 個數,並找出其中的最大值。為此,我們將相互比較這些數字,找出最大的數字
Input: a=2,b=4,c=7 Output:7 Largest Number
說明
此程式僅使用 if 語句找出最大值。
示例
#include <iostream>
using namespace std;
int main() {
int a,b,c;
a=2,b=4,c=7;
if(a>b) {
if(a>c) {
printf("%d Largest Number ",a);
} else {
printf("%d Largest Number ",c);
}
} else {
if(b>c) {
printf("%d Largest Number ",b);
} else {
printf("%d Largest Number ",c);
}
}
return 0;
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP