Write a C++ program to read seven numbers and sorts them in descending order

  • برمجة سي بلس بلس
  • برمجة

Write a C++ program to read seven numbers and sorts them in descending order.

Sample Output:

Sample Input 
2 5 8 9 7 3 4 
sample Output
 9 8 7 5 4 3 2

الأجوبة

#include <iostream>
using namespace std;

int main() {
    int num[7];
    for (int i = 0; i != 7; ++i) {
        cin >> num[i];
    }
    sort(num, num+7);
    cout << " " << num[6]  << " " << num[5]  << " " << num[4]  << " " << num[3]  << " " << num[2] << " " << num[1] << " " << num[0];
    return 0;
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...