Vous êtes sur la page 1sur 2

Estructuras arreglos de estructuras

1) Problema
a) #include<iostream.h>
b) #include<conio.h>
c) #include<iomanip.h>
d) void main()
e) {
f) struct alumno
g) {
h) int codigo;
i) char curso[30];
j) int nota1;
k) int nota2;
l) int nota3;
m) int nota4;
n) float promedio;
o) };
p) alumno alumnosec;
q) cout<<"\n ingrese codigo:";cin>>alumnosec.codigo;
r) cin.ignore();
s) cout<<"ongrese curso:";cin.getline(alumnosec.curso,31);
t) cout<<"ingrese nota1:";cin>>alumnosec.nota1;
u) cout<<"ingrese nota2:";cin>>alumnosec.nota2;
v) cout<<"ingrese nota3:";cin>>alumnosec.nota3;
w) cout<<"ingrese nota4:";cin>>alumnosec.nota4;
x) alumnosec.promedio=(alumnosec.nota1+nota2+nota3+nota4)/3.0;
y) cout<<"\n el promedio es:"<<alumnosec.promedio;
z) cout<<"\n el tamao de la variable alumnosec en bytes es:";
aa) cout<<sizcof(alumnosec);
bb) getch();
cc) }
2) Problema
a) #include<iostream.h>
b) #include<conio.h>
c) #include<iomanip.h>
d) struct ventas{
e) char cod_producto[12];
f) char nombre_producto[50];
g) int cantidad;
h) double precio;
i) double importe;
j) };
k) void main()
l) {
m) const int numero=2;
n) ventas mante_ventas[numero];
o) cout<<"INGRESO DE PRODUCTOS"<<endl;
p) cout<<"--------------------"<<endl;
q) for(int i=0;i<numero;i++)
r) {
s) cout<<"\n datos del producto"<<(i+1)<<endl;
t) cout<<"\n codigo";cin>>mante_ventas[i].cod_producto;
u) cout<<"\n nombre";cin>>mante_ventas[i].nombre_producto;
v) cout<<"\n cantidad";cin>>mante_ventas[i].cantidad;
w) cout<<"\n precio";cin>>mante_ventas[i].precio;
x) mante_ventas[i].importe=mante_ventas[i].cantidad*mante_ventas[i].precio;
y) }
z) cout<<"\n\n REPORTE DEL PRODUCTO \n";
aa) cout<<"--------------------------\n";
bb) cout<<setiosflags(ios::left);
cc) cout<<setw(10)<<"codigo";
dd) cout<<setw(15)<<"nombre";
ee) cout<<setw(10)<<"cantidad";
ff) cout<<setw(12)<<"precio";
gg) cout<<setw(8)<<"importe"<<endl;
hh) for(int c=0;c<numero;c++)
ii) {
jj) cout<<setw(10)<<mante_ventas[c].cod_producto;
kk) cout<<setw(15)<<mante_ventas[c].nombre_producto;
ll) cout<<setw(10)<<mante_ventas[c].cantidad;
mm) cout<<setw(12)<<mante_ventas[c].precio;
nn) cout<<setw(8)<<mante_ventas[c].importe<<endl;
oo) }
pp) getch();
qq) }

Vous aimerez peut-être aussi