👤

Se citesc numere intregi pana la intalnirea lui 0. Scrieti algoritmul care afiseaza cel mai mic sic el mai mare numar citit.

Răspuns :

Răspuns:

#include <bits/stdc++.h>

using namespace std;

int main() {

   int temp = 1, minim = 100001, maxim = -100001;

   while (temp != 0) {

    cin >> temp;

    if (temp < minim && temp != 0) minim = temp;

    if (temp > maxim && temp != 0) maxim = temp;

   } cout << minim << " " << maxim;

   return 0;

}

Explicație: