1234567891011121314151617181920212223242526272829303132333435363738394041
#include <iostream> using namespace std; int main() { int arr[1000]; int temp, n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } cout << endl; cout << "***************Without sort***************" << endl; cout << endl; for (int i = 0; i < n; i++) { cout << arr[i] << endl; } for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { if (arr[j] < arr[j + 1]) { temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } cout << endl; cout << "****************With sort****************" << endl; cout << endl; for (int i = 0; i < n; i++) { cout << arr[i] << endl; } cout << endl << "***************Two large number***************" << endl << arr[0] << endl << arr[1]; return 0; }
12345678910111213141516171819
#include <iostream> using namespace std; int main(){ int a,temp = 0; int arr[1000]; cin >> a; for (int i = 0; i < a; ++i) { cin >> arr[i]; if (arr[i] > temp) { temp = arr[i]; } } cout << temp; return 0; }