Advertisement
Razk2108

Ejemplo Punteros

Jun 3rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5. using namespace System;
  6.  
  7. #define N 4
  8. int main()
  9. {
  10.     float *Apesos;
  11.     Apesos = new float[N];
  12.     //leer
  13.     for (int i = 0;i < N;i++)
  14.     {
  15.         cout << "Ingrese dato: ";cin >> Apesos[i];
  16.     }
  17.     //imprimir
  18.     for (int i = 0;i < N;i++)
  19.         cout << Apesos[i] << endl;
  20.     cout << endl;
  21.     //promedio pesos
  22.     float suma = 0;
  23.     for (int i = 0;i < N;i++)
  24.         suma = suma + Apesos[i];
  25.     cout << "Promedio= " << suma / N << endl;
  26.     //Menores de 40kg
  27.     int cont = 0;
  28.     for (int i = 0;i < N;i++)
  29.         if (Apesos[i] < 40)
  30.             cont++;
  31.     cout << "Menos de 40: " << cont << endl;
  32.     _getch();
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement