tuki2501

bai_3.cpp

Jan 27th, 2021 (edited)
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n, a[100];
  6.   cout << "Nhap n: "; cin >> n;
  7.   for (int i = 0; i < n; i++) {
  8.     cout << "Nhap a[" << i << "] = ";
  9.     cin >> a[i];
  10.   }
  11.   int val = a[0], pos = 0;
  12.   for (int i = 1; i < n; i++) {
  13.     if (a[i] < val) {
  14.       val = a[i];
  15.       pos = i;
  16.     }
  17.   }
  18.   cout << "So nho nhat: " << val << '\n';
  19.   cout << "Vi tri: " << pos << '\n';
  20.   return 0;
  21. }
Add Comment
Please, Sign In to add comment