top of page

Exposición de librerías: ITERATOR - LIMITS

iterator 2.jpg

1

iterator 3.jpg

2

iterator 4.jpg

3

iterator 5.jpg

4

iterator 6.jpg

5

limits 1.jpg

6

limits 2.jpg

7

8

Bibliografía

Ejemplo de aplicación: ITERATOR

#include <iostream>
#include <vector>

using namespace std;
int main()
{
   vector<string>productos={"Teclado","Mouse","Monitor","Gabiente","Parlantes"};
   vector<string>::iterator it1 = productos.begin();
   cout<<*(it1+2)<< endl;
   
   vector<string>::iterator it2 = productos.end();
   cout<<*(it2-1)<< endl;

   return 0;
}

Ejemplo de aplicación: LIMITS

#include <stdio.h>
#include <limits.h>

int main()
{

   printf("Numero de bits del tipo char = %d\n", CHAR_BIT);

   printf("Valor minimo del tipo char con signo = %d\n", SCHAR_MIN);
   printf("Valor maximo del tipo char con signo = %d\n", SCHAR_MAX);
   printf("Valor maximo de unsigned char = %d\n", UCHAR_MAX);

   printf("Valor minimo del tipo short = %d\n", SHRT_MIN);
   printf("Valor maximo del tipo short = %d\n", SHRT_MAX); 

   printf("Valor minimo del tipo int = %d\n", INT_MIN);
   printf("Valor maximo del tipo int = %d\n", INT_MAX);

   printf("Valor minimo del tipo char = %d\n", CHAR_MIN);
   printf("Valor maximo del tipo char = %d\n", CHAR_MAX);

   printf("Valor minimo del tipo long = %ld\n", LONG_MIN);
   printf("Valor maximo del tipo long = %ld\n", LONG_MAX);
 
   return(0);
}

Problemas propuestos en clase

Problema 3.1

# include<iostream>
using namespace std;
int main()

  char c;
  int i='260';
  float f=10.89;
 
  cout<<"     PROBLEMA 3.1     " << endl;
 
  c=i;
  cout<<"\n""c="<<c; //0
  i=f;
  f=i;
  cout<<"\n""f="<<f; //10
  return 0;
}

Problema 3.2

# include<iostream>
using namespace std;
int main()

  int i,j=10;
  float f=10.89;
 
  cout<<"     PROBLEMA 3.2     " << endl;
 
  i=10+0*10;
  f=f/i;
  i=i+1;
  j= i % j;
  cout<<"\n""i="<<i<<"\t\t""f="<<f<<"\t\t""j="<<j; //11  1.089  1
  return 0;
}  

Problema 3.3

# include<iostream>
using namespace std;
int main()

  int i=10,j;
 
  cout<<"     PROBLEMA 3.3     " << endl;
 
  j=i;
  i=i+1;
  cout<<"\n""i x j ="<<i*j; //110
  return 0;

Problema 3.4

# include<iostream>
using namespace std;
int main()

  int i=10,j;
 
  cout<<"     PROBLEMA 3.4     " << endl;
 
  j=i++;
  cout<<"\n""i + j ="<<i+j; //21
  return 0;

Problema 3.5

# include<iostream>
using namespace std;
int main()

  int i=10,j;
 
  cout<<"     PROBLEMA 3.5     " << endl;
 
  i=i+1;
  j=i--;
  cout<<"\n""i="<<i<<"\n""j="<<j;
  return 0;

Problema 3.6

# include<iostream>
using namespace std;
int main()

  int i=10,j;
 
  cout<<"     PROBLEMA 3.6     " << endl;
 
  j=++i;
  cout<<"\n""i x j="<<i*j;
  return 0;
}

Problema 3.7

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
   bool p,q,R;
   
   cout<<"     PROBLEMA 3.7     " << endl;
   cout<<" \n   OPERADOR AND \n";
   cout<<"  -------------- \n";
   p=false;
   q=false;
   R=(p and q);
   cout<<"   p" <<"    q" <<"     R"<<endl;
   cout<<"   0" << "    0" <<"     "  <<R<<endl;
   p=false;
   q=true;
   R=(p and q);
   cout<<"   0" << "    1" <<"     "  <<R<<endl;
   p=true;
   q=false;
   R=(p and q);
   cout<<"   1" << "    0" <<"     "  <<R<<endl;
   p=true;
   q=true;
   R=(p and q);
   cout<<"   1" << "    1" <<"     "  <<R<<endl;
   
   cout<<"\n \n   OPERADOR OR \n";
   cout<<"  -------------- \n";
   p=false;
   q=false;
   R=(p or q);
   cout<<"   p" <<"    q" <<"     R"<<endl;
   cout<<"   0" << "    0" <<"     "  <<R<<endl;
   p=false;
   q=true;
   R=(p or q);
   cout<<"   0" << "    1" <<"     "  <<R<<endl;
   p=true;
   q=false;
   R=(p or q);
   cout<<"   1" << "    0" <<"     "  <<R<<endl;
   p=true;
   q=true;
   R=(p or q);
   cout<<"   1" << "    1" <<"     "  <<R<<endl;
   
   cout<<"\n \n   OPERADOR NOT \n";
   cout<<"  -------------- \n";
   p=false;
   R=(not p);
   cout<<"   p" <<"     R"<<endl;
   cout<<"   0" <<"     "<<R<<endl;
   p=true;
   R=(not p);
   cout<<"   1"<<"     " <<R<<endl;
   
   return 0;
}

Problema 3.8

# include<iostream>
using namespace std;
int main()

  int i=0,j=10,k;
 
  cout<<"     PROBLEMA 3.8     " << endl;
 
  i=((!j)||((j+1)>10));
  k=((j % 2)==0);
  cout<<"\n"<<i <<"\t"<<j <<"\t"<<k; //1 10 1} 
  return 0;
}

Problema 3.9

//Programa para calcular el área de un triángulo
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
  float a,b,c;  // lados del triángulo
  float s;      //semiperímetro      
  float Area;   // área del triángulo
 
  cout<<"     PROBLEMA 3.9: AREA DE UN TRIANGULO     " << endl;
 
  cout <<"\n""Ingrese la longitud de los lados:" <<endl ;
  cin >> a >> b >> c;   // lee los lados
  s = (a + b + c)/2;
  Area = sqrt(s*(s-a)*(s-b)*(s-c));
  cout <<"Area: " << Area << endl;
  return 0; 
}

Problema 3.10

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
   float Radio, Pi=3.1416, Perimetro, Area;
   
   cout<<"  PROBLEMA 3.10: AREA Y PERIMETRO DE UN CIRCULO  " <<endl;
   
   cout <<"\n""Ingrese el valor del Radio:"; cin>>Radio;
   Area=pow(Radio,2)*Pi;
   Perimetro=2*Pi*Radio;
   cout <<"\n""El Area del circulo es:" <<Area <<endl;
   cout <<"\n""El Perimetro del circulo es:" <<Perimetro <<endl;
   return 0;
}

Problema 3.11

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
   float Fuerza, K=8.99*pow(10,9), q1, q2, x1, x2, y1, y2;
   
   cout<<"  PROBLEMA 3.11: FUERZA ENTRE 2 CARGAS  " <<endl;
   
   cout<<"\n""Ingrese el valor de la Carga 1 en micro C:"; cin>>q1;
    cout<<"Ingrese el valor de la Carga 2 en micro C:"; cin>>q2;
    cout<<"Ingrese las coordenadas de la Carga 1:"<<endl; 
   cout<< "x1:"; cin>>x1;
   cout<< "y1:";cin>>y1;
    cout<<"Ingrese las coordenadas de la Carga 2:"<<endl; 
   cout<< "x2:"; cin>>x2;
   cout<< "y2:";cin>>y2;
   
   Fuerza=(K*q1*pow(10,-6)*q2*pow(10,-6))/(pow(x2-x1,2)+pow(y2-y1,2));
   cout<<"La Fuerza es:" <<Fuerza <<endl;
   return 0;
}

bottom of page