WSQ13

P2v2

q1_

Gráfico1.JPG

código:

#include<iostream>

int main()
{
using namespace std;
int num,i,x;
cout << “Dame el tamano del triangulo”<<endl;
cin>>num;
for(i=1;i<=num;i++)
{
for(x=1;x<i+1;x++)
{
cout<<“T”;
}
cout<<endl;
}
for(i=num;i>=1;i=i-1)
{
for(x=i;x>=1;x=x-1)
{
cout<<“T”;
}
cout<<endl;
}
return 0;
}

q2_

Gráfico1.JPG

código:

#include<iostream>
#include<math.h>
long superpower(long a,long b)
{
using namespace std;
long res;
res=pow(a,b);
cout << “El resultado de “<<a<<“^”<<b<<“=”<<res<<endl;
}
int main(){
using namespace std;
long base,exp;
cout << “Dame la base del numero a elevar”<<endl;
cin>>base;
cout << “Dame el exponente del numero a elevar”<<endl;
cin>>exp;
superpower(base,exp);
system(“pause”);
return 0;
}

q3

Gráfico1.JPG

#include<iostream>
#include<math.h>
#include<cstdlib>
long fibonacci (long n){
using namespace std;
long a=1,b=0,res,i;
if(n==2)
{
cout << “El resultado de nivel es 1″<<endl;
}
else
{
if(n==1)
{
cout << “El resultado de nivel es 0″<<endl;
}
else
{
for(i=1;i!=n-1;i++)
{
res=a+b;
b=a;
a=res;
}
cout << “El resultado de nivel es “<<res<<endl;
}
}
}
int main(){
using namespace std;
long num;
cout << “Cual es el nivel al llegar el fibonacci”<<endl;
cin>>num;
fibonacci(num);
system(“pause”);
return 0;
}

CC BY-SA 4.0 WSQ13 by perape is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.