Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
Lista4Ex8.cpp #include <iomanip.h> main() { int c1=0, Canal, c=0, ct=0, idade; float s=0; char r='s', sexo; while(r=='s') { cout << "Entre com o canal assistido (2,6,9,13 ou ZERO):"; cin >> Canal; cout << "Entre com o sexo (f/m):"; cin >> sexo; fflush(stdin); cout << "Entre com a idade:"; cin >> idade; if(sexo == 'f' && (Canal == 2 || Canal == 6)) { c++; } ct++; if(Canal == 0) { s+=idade; c1++; } cout << "Deseja entrar com mais algum valor (s/n)?"; cin >> r; fflush(stdin); } cout << "Letra A:" << c*100.0/ct << "%\n"; if(c1 > 0) { cout << "Letra B: " << s/c1 << "\n"; } else { cout << "Nada a calcular\n"; } system("pause"); } Lista4Ex9.cpp #include <iomanip.h> main() { int c=0, ct=0, c1=0, primeiro=1; float peso, maiorpeso, s=0; char r='s', sexo, resposta; while(r=='s') { cout << "Entre com a resposta (s/n):"; cin >> resposta; fflush(stdin); cout << "Entre com o sexo (f/m):"; cin >> sexo; fflush(stdin); cout << "Entre com o peso:"; cin >> peso; if(sexo == 'f' && resposta == 's') { s+=peso; c1++; } if(sexo == 'm' && resposta == 'n') { if(primeiro) { maiorpeso = peso; primeiro = 0; } else if(peso > maiorpeso) { maiorpeso = peso; } } ct++; if(peso > 110) { c++; } cout << "Deseja entrar com mais algum valor (s/n)?"; cin >> r; fflush(stdin); } if(c1 > 0) { cout << "Letra A: " << s/c1 << "\n"; } else { cout << "Letra A: Nada a calcular\n"; } cout << "Letra B:" << maiorpeso << "\n"; cout << "Letra C:" << c*100/ct << "%\n"; system("pause"); } Lista4Ex10.cpp #include <iomanip.h> main() { int s=0, m=0, h=0; float massa; cout << "Entre com a massa:"; cin >> massa; while(massa>=1) { massa-=massa/10; s++; } cout << "Letra A: " << s << "\n"; while(s>=3600) { h++; s-=3600; } while(s>=60) { m++; s-=60; } cout << "Letra B: "<<h<<":"<<m<<":"<<s<<"\n"; system("pause"); } Lista4Ex1.cpp #include <iomanip.h> main() { int ultimo=1, penultimo=0, novo; cout << penultimo << " "; while(ultimo<=10000) { cout << ultimo << " "; novo = ultimo + penultimo; penultimo = ultimo; ultimo = novo; } system("pause"); } Lista4Ex2.cpp #include <iomanip.h> #include <math.h> main() { float x, y, s=0; int i; cout << "Entre com dois valores:"; cin >> x >> y; if(x*x+y*y*y*y != 0) { for(i=1;i<=1000;i++) { s = s + ( (cos(x) - sin(y)) / sqrt(x*x+y*y*y*y) + i ); } cout << "Soma: " << s; } else { cout << "Impossivel calcular"; } system("pause"); } Lista4Ex3.cpp #include <iomanip.h> main() { int c1=0, c2=0, c3=0, c4=0, i, id; for(i=1;i<=15;i++) { cout << "Entre com a idade:"; cin >> id; if (id>=1 && id<=15) { c1++; // c1 = c1 + 1 } else if (id>=16 && id<=30) { c2++; } else if (id>=31 && id<=45) { c3++; } else if (id>=46 && id<=60) { c4++; } } cout << "Letra A: " << c1 << " " << c2 << " " << c3 << " " << c4 << "\n"; cout << "Letra b: " << c1*100.00/15 << "% " << c2*100.0/15 << "% " << c3*100.0/15 << "% " << c4*100.0/15<<"%"; system("pause"); } Lista4Ex4.cpp #include <iomanip.h> main() { int i; float salario, s=0, pis=0, fgts=0; for(i=1;i<=20;i++) { cout << "Entre com o salario:"; cin >> salario; salario += salario*0.15; cout << "Letra A: Novo Salario R$ "<<salario<<"\n"; s+=salario; pis+=salario * 0.01; fgts+=salario * 0.08; } cout << "Letra B: "<<s<<"\n"; cout << "Letra C: PIS R$"<<pis<<" - FGTS R$"<<fgts<<"\n"; system("pause"); } Lista4Ex5.cpp #include <iomanip.h> main() { int i; float m,n1,n2,n3; for(i=1;i<=20;i++) { cout << "Entre com as tres notas do aluno "<<i<<":"; cin >> n1 >> n2 >> n3; m = (3*n1 + 5*n2 + 10*n3) / 18; if(m>=6) { cout << "Aluno aprovado!\n"; } else { cout << "Aluno reprovado!\n"; } } system("pause"); } Lista4Ex6.cpp #include <iomanip.h> main() { int anos=0; float pa=100000, pb=50000; while(pb<=pa) { pa += 0.02 * pa; pb += 0.03 * pb; anos++; } cout << "Numero de anos:" << anos <<"\n"; system("pause"); } Lista4Ex7.cpp #include <iomanip.h> main() { int i=1; float n1, n2, n3, m; for(;i<=20;i++) { cout << "Entre com as tres notas:"; cin >> n1 >> n2 >> n3; // Zerando notas abaixo de 4 if (n1<4) { n1 = 0; } if (n2<4) { n2 = 0; } if (n3<4) { n3 = 0; } // Calculando a média das duas maiores notas if (n1 >= n2 && n2 >=n3) { m = (n1+n2)/2; } else if (n1 >= n3 && n3 >=n2) { m = (n1+n3)/2; } else if (n2 >= n1 && n1 >=n3) { m = (n2+n1)/2; } else if (n2 >= n3 && n3 >=n1) { m = (n2+n3)/2; } else if (n3 >= n1 && n1 >=n2) { m = (n3+n1)/2; } else if (n3 >= n2 && n2 >=n1) { m = (n3+n2)/2; } // Verificando se aluno passou if(m>=6) { cout << "Aluno aprovado: "<<m<<"\n"; } else { cout << "Aluno reprovado: "<<m<<"\n"; } } system("pause"); }