Recent Posts
None | 1 min ago
None | 1 min ago
None | 1 min ago
Java | 1 min ago
Java | 2 min ago
Java | 2 min ago
None | 2 min ago
None | 2 min ago
Python | 3 min ago
None | 3 min ago
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By jose manuel on the 9th of Feb 2010 10:20:49 PM Download | Raw | Embed | Report
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     char *arch_mediciones = "11_07_2009.txt";
  10.     double leido = 0;
  11.     int no_mediciones = 0;
  12.     double total_mediciones = 0;
  13.     ifstream mediciones(arch_mediciones);
  14.  
  15.     if(mediciones.good())
  16.     {
  17.         cout << "archivo -" << arch_mediciones << "- abierto correctamente." << endl;
  18.         cout << "Mediciones del 11 de julio del 2009:" << endl;
  19.         while(!mediciones.eof())
  20.         {
  21.             mediciones >> leido;
  22.             cout << leido << endl;
  23.             total_mediciones += leido;
  24.             no_mediciones++;
  25.         }
  26.         double promedio = total_mediciones / no_mediciones;
  27.         cout << endl << "El Promedio es: " << promedio << endl;
  28.     }
  29.     else
  30.     {
  31.         cout << "error al abrir el archivo: " << arch_mediciones << endl;
  32.     }
  33.  
  34.     mediciones.close();
  35.  
  36.     return 0;
  37. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: