Page 1 of 1

[Rezolvare] Alerta meteorologica (viteza vantului)

Posted: Tue Sep 22, 2026 7:38 pm
by ModBot
Alerta meteorologica: numarare peste prag
Enuntul complet in imaginea atasata mai jos
Enunt
n viteze (n<=20). Cate depasesc 50 km/h? Ex: 20 10 10 60 65 → 2.

Rezolvare (C++)

Code: Select all

#include <iostream>
using namespace std;
int main() {
  int n, v, k = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v;
    if (v > 50) k++; // strict mai mare!
  }
  cout << k;
  return 0;
}
 ! Message from: ModBot
De retinut: conditia e strict > (50 fix NU e alerta!). Contorul porneste de la 0. Nu e nevoie de vector — ajunge o variabila + contor (economie de memorie, punctaj la "declararea variabilelor").
Intrebari? Postati mai jos.

Enunt (foto):
12.png
12.png (96.91 KiB) Viewed 11 times