Tarefa 13 a comp
Por: Eduardo Bastos • 22/2/2016 • Exam • 479 Palavras (2 Páginas) • 228 Visualizações
Universidade Presbiteriana Mackenzie
Curso: Engenharia Civil
Disciplina: Computação. Algoritmos e Programação II
Professor: Massaki Igarashi
Nome do aluno: Eduardo Bastos
Código de Matrícula: 31557872
Turma de Laboratório: 02S11
Tarefa: Mínima 13a
13.11
#include
#include
using namespace std;
void aep (double b, double h, double &a, double &p)
{
a=b*h;
p=2*(b+h);
}
int main(int argc, char *argv[])
{
double b,h,a,p;
cout<<"base:";cin>>b;
cout<<"altura:";cin>>h;
aep(b,h,a,p);
cout<<"perimetro:"< system("PAUSE"); return EXIT_SUCCESS; } 13.25 #include #include #include using namespace std; void sepex (double d, double &s, double &p, double &x, double &r) { r=d/2; s= M_PI*pow(r,2); p=2*M_PI*r; x=r; } int main(int argc, char *argv[]) { double d,s,p,x,r,y; cout<<"diametro:";cin>>d; sepex (d,s,p,x,r); cout<<"area:"< cout<<"perimetro:"< y=x; cout<<"centroide(x,y):"< system("PAUSE"); return EXIT_SUCCESS; } 13.1
#include
#include
using namespace std;
int f (int n);
int g(int n);
int main(int argc, char *argv[])
{
int n;
cout << "Valor de n: ";cin >> n;
cout << "f(n): " << f(n) << endl << "g(n): " << g(n) << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
int f (int n)
{
if(n<3)
return 3-n;
else
return 2*f(n-1)+g(n-2);
}
int g(int n)
{
if(n<3)
return n;
else
return g(n-1)+3*f(n-2);
}
13.12
#include
#include
#include
using namespace std;
void sencos (double r, double &s, double &c)
{
s = sin(r);
c = cos(r);
}
int main(int argc, char *argv[])
{
double r,g,s,c;
cout << "Graus: "; cin >> g;
r = g*M_PI/180;
sencos(r,s,c);
cout << "sen(" << g << "): " << s << endl;
cout << "cos(" << g << "): " << c << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
13.13
#include
#include
#include
using namespace std;
double dobro (double x)
{
return 2 * x;
}
void dobro (double x, double &y)
{
y = 2 * x;
}
int main(int argc, char *argv[])
{
double x,y;
cout << "Valor: "; cin >> x;
dobro(x,y);
cout << "Dobro de " << x << ": " << y << endl;
cout << "Dobro de " << x << ": " << dobro(x) << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
13.15
#include
#include
#include
using namespace std;
double dobrotriplo (double x, double &y)
{
y = 3*x;
return 2 * x;
}
void dobrotriplo (double x, double &y, double &z)
{
y = 2 * x;
z = 3 * x;
}
int main(int argc, char *argv[])
{
double x,y,z;
cout << "Valor: "; cin >> x;
dobrotriplo(x,y,z);
cout << "Dobro de " << x << ": " << y << " | " << "Triplo de " << x << ": " << z << endl;
cout << "Dobro de " << x << ": " << dobrotriplo(x,y) << " | " << "Triplo de " << x << ": " << y << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
13.34
#include
#include
#include
using namespace std;
void succ(int &x)
{
x+=1;
}
int main(int argc, char *argv[])
{
int x;
cout << "Valor: "; cin >> x;
succ(x);
cout << "Sucessor: " << x << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
13.36
#include
#include
#include
using namespace std;
void inc(int &x, int q=1)
{
x+=q;
}
int main(int argc, char *argv[])
{
int x,q;
cout << "Valor: "; cin >> x;
cout << "Incremento: "; cin>> q;
inc(x,q);
cout<< "Resultado: " << x << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
...