ordenar los numeros positivos y negativos en forma ascendente en 2 arreglos diferentes
Publicado por Cristina (13 intervenciones) el 05/12/2020 23:24:32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
const int talla=20;
int main() {
int i,numeros[talla];
int positivos=0, negativos=0, nulos=0;
//llenar el vector
for (i=0; i<talla; i++) {
cout << "Digite el numero " << i+1 <<": ";
cin >> numeros[i];
}
//contar positivos y negativos
for (i=0; i<talla; i++) {
if (numeros[i] > 0)
positivos++;
else
negativos++;
}
for (i=0;i<talla; i++) {
if (numeros[i]==0)
nulos++;
}
//Mostrar resultados
cout << "\nTotal numeros positivos: " << positivos << endl;
cout << "Total numeros negativos: " << negativos << endl;
cout << "Total de numeros nulos:"<< nulos << endl;
return 0;
}
Valora esta pregunta


0