> firstName >> lastName; salida << "Student Name: " << firstName << " " << lastName << endl; entrada >> test1 >> test2 >> test3 >> test4 >> test5; salida << "Test Scores: " << setw(6) << test1 << setw(6) << test2 << setw(6) << test3 << setw(6) << test4 << setw(6) << test5 << endl; average = (test1 + test2 + test3 + test4 + test5 ) / 5.0; salida << "Average test score: " << setw(6) << average << endl; } entrada.close(); salida.close(); cout << "Fin del procesamiento de archivos..." << endl; system("pause"); return 0; // EJEMPLO DE UN PROGRAMA QUE PROCESA ARCHIVOS DE DATOS // EN C++ #include #include #include #include using namespace std; int main() { ifstream entrada; ofstream salida; double test1, test2, test3, test4, test5; double average; string firstName; string lastName; entrada.open("est.txt"); salida.open("promedios.out");"> > firstName >> lastName; salida << "Student Name: " << firstName << " " << lastName << endl; entrada >> test1 >> test2 >> test3 >> test4 >> test5; salida << "Test Scores: " << setw(6) << test1 << setw(6) << test2 << setw(6) << test3 << setw(6) << test4 << setw(6) << test5 << endl; average = (test1 + test2 + test3 + test4 + test5 ) / 5.0; salida << "Average test score: " << setw(6) << average << endl; } entrada.close(); salida.close(); cout << "Fin del procesamiento de archivos..." << endl; system("pause"); return 0; // EJEMPLO DE UN PROGRAMA QUE PROCESA ARCHIVOS DE DATOS // EN C++ #include #include #include #include using namespace std; int main() { ifstream entrada; ofstream salida; double test1, test2, test3, test4, test5; double average; string firstName; string lastName; entrada.open("est.txt"); salida.open("promedios.out");">

La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Ejemplo de un programa en C++ donde se manipulan archivos de datos

Presentaciones similares


Presentación del tema: "Ejemplo de un programa en C++ donde se manipulan archivos de datos"— Transcripción de la presentación:

1 Ejemplo de un programa en C++ donde se manipulan archivos de datos
Prof. Carlos A. Rodríguez Sánchez

2 salida << setprecision(2);
salida << fixed << showpoint; salida << setprecision(2); cout << "Procesando los datos:" << endl; while (!entrada.eof()) { entrada >> firstName >> lastName; salida << "Student Name: " << firstName << " " << lastName << endl; entrada >> test1 >> test2 >> test3 >> test4 >> test5; salida << "Test Scores: " << setw(6) << test1 << setw(6) << test2 << setw(6) << test3 << setw(6) << test4 << setw(6) << test5 << endl; average = (test1 + test2 + test3 + test4 + test5 ) / 5.0; salida << "Average test score: " << setw(6) << average << endl; } entrada.close(); salida.close(); cout << "Fin del procesamiento de archivos..." << endl; system("pause"); return 0; // EJEMPLO DE UN PROGRAMA QUE PROCESA ARCHIVOS DE DATOS // EN C++ #include<iostream> #include<fstream> #include<iomanip> #include<string> using namespace std; int main() { ifstream entrada; ofstream salida; double test1, test2, test3, test4, test5; double average; string firstName; string lastName; entrada.open("est.txt"); salida.open("promedios.out");

3 Archivo de Datos de entrada
Andrew Miller John Doe Jane Doe Archivo de Salida Student Name: Andrew Miller Test Scores: Average test score: Student Name: John Doe Test Scores: Average test score: Student Name: Jane Doe Test Scores: Average test score:

4 NotePad

5 Archivos

6

7


Descargar ppt "Ejemplo de un programa en C++ donde se manipulan archivos de datos"

Presentaciones similares


Anuncios Google