Escolar Documentos
Profissional Documentos
Cultura Documentos
ALUMNO:
YERALDO MOREIRA VALDIVIESO
PARALELO: A
PERIODO
OCTUBRE 2014 FEBRERO 2015
PORTOVIEJO MANAB ECUADOR
ndice
Contenido
Contenido del trabajo solicitado................................................................................................5
Funciones con parmetros, primera forma
Codigo.......................................................................................................................................6
Prueba de escritorio..................................................................................................................6
Funciones con parmetros, segunda forma
Codigo.......................................................................................................................................7
Prueba de escritorio..................................................................................................................7
Funciones con parmetros, tercera forma
Codigo.......................................................................................................................................8
Prueba de escritorio..................................................................................................................8
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
35
36
37
38
39
#include <iostream>
#include <string.h>
using namespace std;
struct mystruct{
string name, lastn, address;
int id;
}pacient[20];
int llenar(mystruct &pacient){ // Funcin con parmetros, primera forma:
cin.get();
cout << "Nombres: "; getline (cin, pacient.name);
cout << "Apellidos: "; getline(cin, pacient.lastn);
cout << "Direccion: "; getline(cin, pacient.address);
cout << "CI: "; cin >> pacient.id;
return 0;
}
int mostrar (mystruct &pacient){
cout << "\tDatos ingresados\n"
<< "**" << pacient.name
<< endl << "**" << pacient.lastn
<< endl << "**" << pacient.address
<< endl << "**" << pacient.id << endl;
return 0;
}
int main()
{
int counter;
cout << "\tFunciones con parmetros; 1 forma:\n";
cout << "Numero de pacientes?: "; cin >> counter;
for (int i=0; i<counter; ++i){
llenar(pacient[i]);
}
for (int i=0; i<counter; ++i){
cout << "Para el paciente numero #"<<i+1<<": \n";
mostrar(pacient[i]);
}
}
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
35
#include <iostream>
#include <string.h>
using namespace std;
struct mystruct{
string name, lastn, address;
int id;
}pacient[20];
int llenar_2(string name, string lastn, string address, int id ){ // Funcin con parmetros,
segunda forma:
pacient[0].name = "Yeraldo Nicolas";
pacient[0].lastn = "Moreira Valdivieso";
pacient[0].address = "Vicente Macas y 27 de Julio";
pacient[0].id = 1310836042;
return 0;
}
int mostrar_2(string name, string lastn, string address, int id){
cout << "\tDatos ingresados\n"
<< "**" << pacient[0].name
<< endl << "**" << pacient[0].lastn
<< endl << "**" << pacient[0].address
<< endl << "**" << pacient[0].id << endl;
return 0;
}
int main()
{
cout << "\tFunciones con parmetros; 2 forma:\n";
llenar_2("nombres", "apellidos", "direccin", 131);
mostrar_2("nombres", "apellidos", "direccin", 131);
return 0;
}
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
#include <iostream>
#include <string.h>
using namespace std;
struct mystruct{
string name, lastn, address;
int id;
}pacient[20];
int llenar_3(string name, string lastn, string address, int id){ // Funcin con parmetros, tercera
forma:
cout << "Nombres: "; getline (cin, pacient[0].name);
cout << "Apellidos: "; getline(cin, pacient[0].lastn);
cout << "Direccion: "; getline(cin, pacient[0].address);
cout << "CI: "; cin >> pacient[0].id;
return 0;
}
int mostrar_3(string name, string lastn, string address, int id){
cout << "\tDatos ingresados\n"
<< "**" << pacient[0].name
<< endl << "**" << pacient[0].lastn
<< endl << "**" << pacient[0].address
<< endl << "**" << pacient[0].id << endl;
return 0;
}
int main()
{
cout << "\tFunciones con parmetros; 3 forma:\n";
llenar_3(pacient[0].name, pacient[0].lastn, pacient[0].address, pacient[0].id);
mostrar_3(pacient[0].name, pacient[0].lastn, pacient[0].address, pacient[0].id);
return 0;
}