tuki2501

vi_tri_cac_so_nho_nhat.cpp

Jan 27th, 2021 (edited)
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 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: ";
  7.   cin >> n;
  8.   for (int i = 0; i < n; i++) {
  9.     cout << "Nhap a[" << i << "] = ";
  10.     cin >> a[i];
  11.   }
  12.   int mi = a[0];
  13.   for (int i = 1; i < n; i++) {
  14.     if (a[i] < mi) mi = a[i];
  15.   }
  16.   cout << "Vi tri cac so nho nhat: ";
  17.   for (int i = 0; i < n; i++) {
  18.     if (a[i] == mi) cout << i << ' ';
  19.   }
  20. }
Add Comment
Please, Sign In to add comment