miércoles, 15 de octubre de 2014
miércoles, 6 de agosto de 2014
Es el codigo VrmlPad con las figuras geométricas
#VRML V2.0 utf8
Collision {
collide FALSE
children [
Transform {
translation -3 0 0
children [
Shape {
geometry Box {
size 2 2 2
}
appearance Appearance {
material Material {
diffuseColor 1 0 0
}
}
}
]
}
]
}
Collision {
collide TRUE
children [
Shape {
geometry Sphere {
radius 1
}
appearance Appearance {
material Material {
diffuseColor 0 1 0
}
}
}
Transform {
translation 5 0 0
children [
Shape {
appearance Appearance {
material Material{
diffuseColor .576 .8 .306
specularColor .235 .576 .863
emissiveColor .424 .702 .22
}
}
geometry Cone { height 3.0
bottomRadius 0.75}
}
]
}
Transform {
translation 3 0 0
children [
Shape {
geometry Cylinder {height 1
}
appearance Appearance {
material Material {
diffuseColor 0 0.5 1
}
}
}
]
}
]
}
Collision {
collide FALSE
children [
Transform {
translation -3 0 0
children [
Shape {
geometry Box {
size 2 2 2
}
appearance Appearance {
material Material {
diffuseColor 1 0 0
}
}
}
]
}
]
}
Collision {
collide TRUE
children [
Shape {
geometry Sphere {
radius 1
}
appearance Appearance {
material Material {
diffuseColor 0 1 0
}
}
}
Transform {
translation 5 0 0
children [
Shape {
appearance Appearance {
material Material{
diffuseColor .576 .8 .306
specularColor .235 .576 .863
emissiveColor .424 .702 .22
}
}
geometry Cone { height 3.0
bottomRadius 0.75}
}
]
}
Transform {
translation 3 0 0
children [
Shape {
geometry Cylinder {height 1
}
appearance Appearance {
material Material {
diffuseColor 0 0.5 1
}
}
}
]
}
]
}
Este es el codigo VrmlPad: es un cuarto ahí les dejo para que lo miren
#VRML V2.0 utf8
Group {
children [
#PISO
Transform {translation 0.0 -0.1 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box { size 4 0.1 4}}]}
#PARED DERECHA
Transform {translation 2 0.9 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box { size 0.1 2 4}}]},
#PARED IZQUIERDA
Transform {translation -2 0.9 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box { size 0.1 2 4}}]},
#PARED FONDO
Transform {translation 0.0 1.1 0.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box {size 4 2.5 0.1}},]},
#CAMA
Transform {translation 0.0 0.11 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 3 0.1 0.2}}
geometry Box { size 1.5 0.5 2}}]},
#SABANA
Transform {translation 0.0 0.4 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 0.8 0.8 0.8}}
geometry Box { size 1.3 0.1 1.85}}]},
#ALMUADAS DERECHA
Transform {translation 0.3 0.5 1.3 children [
Shape {appearance Appearance {material Material {diffuseColor 0.2 0.9 0.1}}
geometry Box { size 0.3 0.1 0.2}}]},
#ALMUADAS IZQUIERDA
Transform {translation -0.3 0.5 1.3 children [
Shape {appearance Appearance {material Material {diffuseColor 0.2 0.9 0.1}}
geometry Box { size 0.3 0.1 0.2}}]},
#ARMARIO
Transform {translation 1.76 0.55 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 4 0.1 0.2}}
geometry Box { size 0.55 1.3 1.3}}]},
#ARMARIO PUERTA DERECHA
Transform {translation 1.5 0.53 0.9 children [
Shape {appearance Appearance {material Material {diffuseColor 1 0.85 0}}
geometry Box { size 0.1 1.3 0.6}}]},
#ARMARIO PUERTA IZQUIERDA
Transform {translation 1.24 0.55 1.82 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box {size 0.5 1.3 0.06}},]},
#COMODA 1
Transform {translation 1.76 0.3 3 children [
Shape {appearance Appearance {material Material {diffuseColor 4 0.1 0.2}}
geometry Box { size 0.5 0.8 1}}]},
#CAJONE SUPERIOR
Transform {translation 1.5 0.55 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE CENTRAL
Transform {translation 1.5 0.3 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE INFERIOR
Transform {translation 1.5 0.065 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#PERILLA SUPERIOR
Transform {translation 1.43 0.55 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA CENTRAL
Transform {translation 1.43 0.3 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA INFERIOR
Transform {translation 1.43 0.065 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#COMODA 2
Transform {translation -1.76 0.3 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 4 0.1 0.2}}
geometry Box { size 0.5 0.8 1}}]},
#CAJONE SUPERIOR2
Transform {translation -1.5 0.55 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE CENTRAL2
Transform {translation -1.5 0.3 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE INFERIOR2
Transform {translation -1.5 0.065 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#PERILLA SUPERIOR2
Transform {translation -1.43 0.55 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA CENTRAL2
Transform {translation -1.43 0.3 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA INFERIOR2
Transform {translation -1.43 0.065 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#LAMPARA ESFERA
Transform {translation -1.65 0.95 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.1 }}]},
#LAMPARA CILINDRO
Transform {translation -1.65 0.87 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Cylinder { height 0.05 radius 0.12}}]},
#LAMPARA CILINDRO
Transform {translation -1.65 0.87 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Cylinder { height 0.05 radius 0.12}}]},
#LAMPARA CILINDRO2
Transform {translation -1.65 0.8 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Cylinder { height 0.2 radius 0.05}}]},
#CUADRO
Transform {translation -1.65 0.8 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor .88 .32 .2
specularColor .82 .28 .28
ambientIntensity .113
shininess .8}}
geometry Box { size .07 .2 .3}}]},
]}
Group {
children [
#PISO
Transform {translation 0.0 -0.1 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box { size 4 0.1 4}}]}
#PARED DERECHA
Transform {translation 2 0.9 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box { size 0.1 2 4}}]},
#PARED IZQUIERDA
Transform {translation -2 0.9 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box { size 0.1 2 4}}]},
#PARED FONDO
Transform {translation 0.0 1.1 0.0 children [
Shape {appearance Appearance {material Material {diffuseColor 2 0 2}}
geometry Box {size 4 2.5 0.1}},]},
#CAMA
Transform {translation 0.0 0.11 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 3 0.1 0.2}}
geometry Box { size 1.5 0.5 2}}]},
#SABANA
Transform {translation 0.0 0.4 2.0 children [
Shape {appearance Appearance {material Material {diffuseColor 0.8 0.8 0.8}}
geometry Box { size 1.3 0.1 1.85}}]},
#ALMUADAS DERECHA
Transform {translation 0.3 0.5 1.3 children [
Shape {appearance Appearance {material Material {diffuseColor 0.2 0.9 0.1}}
geometry Box { size 0.3 0.1 0.2}}]},
#ALMUADAS IZQUIERDA
Transform {translation -0.3 0.5 1.3 children [
Shape {appearance Appearance {material Material {diffuseColor 0.2 0.9 0.1}}
geometry Box { size 0.3 0.1 0.2}}]},
#ARMARIO
Transform {translation 1.76 0.55 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 4 0.1 0.2}}
geometry Box { size 0.55 1.3 1.3}}]},
#ARMARIO PUERTA DERECHA
Transform {translation 1.5 0.53 0.9 children [
Shape {appearance Appearance {material Material {diffuseColor 1 0.85 0}}
geometry Box { size 0.1 1.3 0.6}}]},
#ARMARIO PUERTA IZQUIERDA
Transform {translation 1.24 0.55 1.82 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box {size 0.5 1.3 0.06}},]},
#COMODA 1
Transform {translation 1.76 0.3 3 children [
Shape {appearance Appearance {material Material {diffuseColor 4 0.1 0.2}}
geometry Box { size 0.5 0.8 1}}]},
#CAJONE SUPERIOR
Transform {translation 1.5 0.55 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE CENTRAL
Transform {translation 1.5 0.3 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE INFERIOR
Transform {translation 1.5 0.065 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#PERILLA SUPERIOR
Transform {translation 1.43 0.55 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA CENTRAL
Transform {translation 1.43 0.3 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA INFERIOR
Transform {translation 1.43 0.065 3 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#COMODA 2
Transform {translation -1.76 0.3 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 4 0.1 0.2}}
geometry Box { size 0.5 0.8 1}}]},
#CAJONE SUPERIOR2
Transform {translation -1.5 0.55 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE CENTRAL2
Transform {translation -1.5 0.3 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#CAJONE INFERIOR2
Transform {translation -1.5 0.065 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Box { size .05 0.2 .9}}]},
#PERILLA SUPERIOR2
Transform {translation -1.43 0.55 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA CENTRAL2
Transform {translation -1.43 0.3 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#PERILLA INFERIOR2
Transform {translation -1.43 0.065 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.05 }}]},
#LAMPARA ESFERA
Transform {translation -1.65 0.95 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Sphere { radius 0.1 }}]},
#LAMPARA CILINDRO
Transform {translation -1.65 0.87 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Cylinder { height 0.05 radius 0.12}}]},
#LAMPARA CILINDRO
Transform {translation -1.65 0.87 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Cylinder { height 0.05 radius 0.12}}]},
#LAMPARA CILINDRO2
Transform {translation -1.65 0.8 1.6 children [
Shape {appearance Appearance {material Material {diffuseColor 1 .85 0}}
geometry Cylinder { height 0.2 radius 0.05}}]},
#CUADRO
Transform {translation -1.65 0.8 1.2 children [
Shape {appearance Appearance {material Material {diffuseColor .88 .32 .2
specularColor .82 .28 .28
ambientIntensity .113
shininess .8}}
geometry Box { size .07 .2 .3}}]},
]}
domingo, 11 de mayo de 2014
Sacar Cantidad en c++
#include<iostream.h>
#include<conio.h>
void main()
{
int CANT, B20, B10, B5, B1;
clrscr();
cout<<"Ingrese cantidad: ";cin>>CANT;
B20 = CANT/20;
CANT = CANT%20;
B10 = CANT/10;
CANT = CANT%10;
B5 = CANT/5;
B1 = CANT%5;
cout<<"Billetes de 20: "<<B20;
cout<<"Billetes de 10: "<<B10;
cout<<"Billetes de 5: "<<B5;
cout<<"Billetes de 1: "<<B1;
getch();
}
#include<conio.h>
void main()
{
int CANT, B20, B10, B5, B1;
clrscr();
cout<<"Ingrese cantidad: ";cin>>CANT;
B20 = CANT/20;
CANT = CANT%20;
B10 = CANT/10;
CANT = CANT%10;
B5 = CANT/5;
B1 = CANT%5;
cout<<"Billetes de 20: "<<B20;
cout<<"Billetes de 10: "<<B10;
cout<<"Billetes de 5: "<<B5;
cout<<"Billetes de 1: "<<B1;
getch();
}
Invertir numero en c++
#include<iostream.h>
#include<conio.h>
void main()
{
int NUM, NUMINV, U, D, C, AUX;
clrscr();
cout<<"Ingrese número: ";cin>>NUM;
AUX = NUM;
C = NUM/100;
NUM = NUM%100;
D = NUM/10;
U = NUM%10;
NUMINV = U*100 + D*10 + C;
cout<<"El numero es A es: "<<AUX;
cout<<"El invertido: "<<NUMINV;
getch();
}
#include<conio.h>
void main()
{
int NUM, NUMINV, U, D, C, AUX;
clrscr();
cout<<"Ingrese número: ";cin>>NUM;
AUX = NUM;
C = NUM/100;
NUM = NUM%100;
D = NUM/10;
U = NUM%10;
NUMINV = U*100 + D*10 + C;
cout<<"El numero es A es: "<<AUX;
cout<<"El invertido: "<<NUMINV;
getch();
}
Contador un poco difícil en c++
#include<iostream.h>
#include<conio.h>
void main()
{
int A, B, C,D, E, AUX1, AUX2;
clrscr();
cout<<"Ingrese A: ";cin>>A;
cout<<"Ingrese B: ";cin>>B;
cout<<"Ingrese C: ";cin>>C;
cout<<"Ingrese D: ";cin>>D;
cout<<"Ingrese E: ";cin>>E;
AUX1 = A;
AUX2 = D;
A = C;
D = B;
B = E;
E = AUX1;
C = AUX2;
cout<<"El valor de A es: "<<A;
cout<<"El valor de B es: "<<B;
cout<<"El valor de C es: "<<C;
cout<<"El valor de D es: "<<D;
cout<<"El valor de E es: "<<E;
getch();
}
#include<conio.h>
void main()
{
int A, B, C,D, E, AUX1, AUX2;
clrscr();
cout<<"Ingrese A: ";cin>>A;
cout<<"Ingrese B: ";cin>>B;
cout<<"Ingrese C: ";cin>>C;
cout<<"Ingrese D: ";cin>>D;
cout<<"Ingrese E: ";cin>>E;
AUX1 = A;
AUX2 = D;
A = C;
D = B;
B = E;
E = AUX1;
C = AUX2;
cout<<"El valor de A es: "<<A;
cout<<"El valor de B es: "<<B;
cout<<"El valor de C es: "<<C;
cout<<"El valor de D es: "<<D;
cout<<"El valor de E es: "<<E;
getch();
}
Contador en c++
#include<iostream.h>
#include<conio.h>
void main()
{
int A, B, C, AUX;
clrscr();
cout<<"Ingrese A: ";cin>>A;
cout<<"Ingrese B: ";cin>>B;
cout<<"Ingrese C: ";cin>>C;
AUX = A;
A = B;
B = C;
C = AUX;
cout<<"El valor de A es: "<<A;
cout<<"El valor de B es: "<<B;
cout<<"El valor de C es: "<<C;
getch();
}
#include<conio.h>
void main()
{
int A, B, C, AUX;
clrscr();
cout<<"Ingrese A: ";cin>>A;
cout<<"Ingrese B: ";cin>>B;
cout<<"Ingrese C: ";cin>>C;
AUX = A;
A = B;
B = C;
C = AUX;
cout<<"El valor de A es: "<<A;
cout<<"El valor de B es: "<<B;
cout<<"El valor de C es: "<<C;
getch();
}
El área de un cubo en c++
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float L1, L2, L3, S, Area;
clrscr();
cout<<"Lado 1: ";cin>>L1;
cout<<"Lado 2: ";cin>>L2;
cout<<"Lado 3: ";cin>>L3;
S = (L1 + L2 + L3) / 2;
Area = pow(S*(S-L1)*(S-L2)*(S-L3),0.5);
cout<<"El area es: "<<Area;
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
float L1, L2, L3, S, Area;
clrscr();
cout<<"Lado 1: ";cin>>L1;
cout<<"Lado 2: ";cin>>L2;
cout<<"Lado 3: ";cin>>L3;
S = (L1 + L2 + L3) / 2;
Area = pow(S*(S-L1)*(S-L2)*(S-L3),0.5);
cout<<"El area es: "<<Area;
getch();
}
Suma de vectores en Java
import java .io.*;
public class Sumavec
{
public static void main (String args[])
{
InputStreamReader s=new InputStreamReader (System.in);
BufferedReader va=new BufferedReader (s);
try
{
int [] vec1;
vec1 = new int [10];
int [] vec2;
vec2 = new int [10];
int [] vecsum;
vecsum = new int [10];
System.out.println ("Dame diez numeros..");
for (int k=0; k<10; k++)
{
int n = Integer.parseInt (va.readLine());
vec1[k]= n;
}
System.out.println ("dame diez numeros");
for (int k=0; k<10; k++)
{
int n= Integer.parseInt (va.readLine());
vec2[k]= n;
}
for ( int k=0; k<10; k++)
{
vecsum[k] = vec1[k]+ vec2[k];
}
for (int k=0; k<10; k++)
{
System.out.println ("la suma de vector uno y vector dos es: "+vecsum[k]);
}
}//cierra try
catch (Exception e)
{
e.printStackTrace ();
}
}
}
public class Sumavec
{
public static void main (String args[])
{
InputStreamReader s=new InputStreamReader (System.in);
BufferedReader va=new BufferedReader (s);
try
{
int [] vec1;
vec1 = new int [10];
int [] vec2;
vec2 = new int [10];
int [] vecsum;
vecsum = new int [10];
System.out.println ("Dame diez numeros..");
for (int k=0; k<10; k++)
{
int n = Integer.parseInt (va.readLine());
vec1[k]= n;
}
System.out.println ("dame diez numeros");
for (int k=0; k<10; k++)
{
int n= Integer.parseInt (va.readLine());
vec2[k]= n;
}
for ( int k=0; k<10; k++)
{
vecsum[k] = vec1[k]+ vec2[k];
}
for (int k=0; k<10; k++)
{
System.out.println ("la suma de vector uno y vector dos es: "+vecsum[k]);
}
}//cierra try
catch (Exception e)
{
e.printStackTrace ();
}
}
}
Para sacar distancia y velocidad en c++
#include<iostream.h>
#include<conio.h>
void main()
{
int MIN, SEG, CEN;
float DIST, TIEMSEG, VELOKH;
clrscr();
cout<<"Min: ";cin>>MIN;
cout<<"SEG: ";cin>>SEG;
cout<<"CEN: ";cin>>CEN;
cout<<"Distancia: ";cin>>DIST;
VELOKH = (DIST/(MIN*60+SEG+CEN/100))*3.6;
cout<<"Distancia: "<<DIST/1000<<" km";
cout<<"Velocidad: "<<VELOKH<<" (K/H)";
getch();
}
#include<conio.h>
void main()
{
int MIN, SEG, CEN;
float DIST, TIEMSEG, VELOKH;
clrscr();
cout<<"Min: ";cin>>MIN;
cout<<"SEG: ";cin>>SEG;
cout<<"CEN: ";cin>>CEN;
cout<<"Distancia: ";cin>>DIST;
VELOKH = (DIST/(MIN*60+SEG+CEN/100))*3.6;
cout<<"Distancia: "<<DIST/1000<<" km";
cout<<"Velocidad: "<<VELOKH<<" (K/H)";
getch();
}
Hallar el área,altura,radio,volumen de una circunferencia en c++
#include<iostream.h>
#include<conio.h>
#include<math.h>
#define PI 3.1416
void main()
{
float RADIO, ALTU, Area, Vol;
clrscr();
cout<<"Ingrese Radio: ";cin>>RADIO;
cout<<"Ingrese Altura: ";cin>>ALTU;
Area = 2 * PI * RADIO * ALTU;
Vol = PI * pow(RADIO,2) * ALTU;
cout<<"El area es: "<<Area;
cout<<"El volumen es: "<<Vol;
getch();
}
#include<conio.h>
#include<math.h>
#define PI 3.1416
void main()
{
float RADIO, ALTU, Area, Vol;
clrscr();
cout<<"Ingrese Radio: ";cin>>RADIO;
cout<<"Ingrese Altura: ";cin>>ALTU;
Area = 2 * PI * RADIO * ALTU;
Vol = PI * pow(RADIO,2) * ALTU;
cout<<"El area es: "<<Area;
cout<<"El volumen es: "<<Vol;
getch();
}
Convertidor de dolares a soles peruanos en c++
#include<iostream.h>
#include<conio.h>
void main()
{
float CANT;
clrscr();
cout<<"Ingrese cantidad $: ";cin>>CANT;
CANT = CANT * 3.25;
cout<<"Cambio en Soles : "<<CANT;
getch();
}
#include<conio.h>
void main()
{
float CANT;
clrscr();
cout<<"Ingrese cantidad $: ";cin>>CANT;
CANT = CANT * 3.25;
cout<<"Cambio en Soles : "<<CANT;
getch();
}
Sacar peso,longitud en c++
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
char NOM[50];
float PES, LON;
clrscr();
cout<<"Ingrese nombre del dinosaurio: ";cin>>NOM;
cout<<"Ingrese su peso en libras: ";cin>>PES;
cout<<"Ingrese su longitus en pies: ";cin>>LON;
PES = PES * 0.4535924;
LON = LON * 0.3048006;
cout<<"El Dinosaurio es : "<<NOM;
cout<<"su peso en KG es : "<<PES;
cout<<"Su lngituda en metros es : "<<LON;
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
char NOM[50];
float PES, LON;
clrscr();
cout<<"Ingrese nombre del dinosaurio: ";cin>>NOM;
cout<<"Ingrese su peso en libras: ";cin>>PES;
cout<<"Ingrese su longitus en pies: ";cin>>LON;
PES = PES * 0.4535924;
LON = LON * 0.3048006;
cout<<"El Dinosaurio es : "<<NOM;
cout<<"su peso en KG es : "<<PES;
cout<<"Su lngituda en metros es : "<<LON;
getch();
}
Para sacar nota a nivel simple en c++
#include<iostream.h>
#include<conio.h>
void main()
{
float NOTA;
clrscr();
cout<<"Ingrese su nota por favor| ";
cin>>NOTA;
if(NOTA>=0 & NOTA<=10)
{
if(NOTA==10)
{cout<<"Matricula de honor";}
if(NOTA>=8.5 & NOTA<10)
{cout<<"Sobresaliente";}
if(NOTA>=6.5 & NOTA<8.5)
{cout<<"Notable";}
if(NOTA>=5 & NOTA<6.5)
{cout<<"Aprobado";}
if(NOTA>=0 & NOTA<5)
{cout<<"Suspenso";}
}
else
{cout<<"Nota invalida";}
getch();
}
#include<conio.h>
void main()
{
float NOTA;
clrscr();
cout<<"Ingrese su nota por favor| ";
cin>>NOTA;
if(NOTA>=0 & NOTA<=10)
{
if(NOTA==10)
{cout<<"Matricula de honor";}
if(NOTA>=8.5 & NOTA<10)
{cout<<"Sobresaliente";}
if(NOTA>=6.5 & NOTA<8.5)
{cout<<"Notable";}
if(NOTA>=5 & NOTA<6.5)
{cout<<"Aprobado";}
if(NOTA>=0 & NOTA<5)
{cout<<"Suspenso";}
}
else
{cout<<"Nota invalida";}
getch();
}
Para sacar el Radio,área de una circunferencia en c++
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float R,A,PI;
PI=3.1416;
clrscr();
cout<<"Ingrese radio: ";cin>>R;
A = PI * pow(R,2);
cout<<"El área es: "<<A;
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
float R,A,PI;
PI=3.1416;
clrscr();
cout<<"Ingrese radio: ";cin>>R;
A = PI * pow(R,2);
cout<<"El área es: "<<A;
getch();
}
Para sacar altura,base,perímetro y superficie de un Rectángulo
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float B, A, PER, SUP;
clrscr();
cout<<"Ingrese altura del rectangulo: ";cin>>A;
cout<<"Ingrese base del rectangulo: ";cin>>B;
PER = (B + A) * 2;
SUP = B * A;
cout<<"El perímetro es: "<<PER;
cout<<"La superficie es: "<<SUP;
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
float B, A, PER, SUP;
clrscr();
cout<<"Ingrese altura del rectangulo: ";cin>>A;
cout<<"Ingrese base del rectangulo: ";cin>>B;
PER = (B + A) * 2;
SUP = B * A;
cout<<"El perímetro es: "<<PER;
cout<<"La superficie es: "<<SUP;
getch();
}
Arreglos con ejemplo de caracteres en c++
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class Persona
{
private:
char Nombre[26];
char Apellido[26];
char Direccion[31];
char Telefono[8];
public:
Persona();
Persona(char n[], char *a, char *d, char *t);
void Leer();
void Imprimir();
};
class Estudiante : public Persona
{
private:
char Univ[20];
char Espe[20];
public:
Estudiante();
void Leer();
void ImprimirDatos();
};
Estudiante::Estudiante(): Persona("X","Y","Z","Z")
{
Univ[0]=0;
Espe[0]=0;
}
void Estudiante::Leer()
{
Persona::Leer();
cout<<"Universidad: ";gets(Univ);
cout<<"Especialidad: ";gets(Espe);
}
void Estudiante::ImprimirDatos()
{
Imprimir();
cout<<"\nUniversidad : "<<Univ;
cout<<"\nEspecialidad: "<<Espe;
}
Persona::Persona()
{
Nombre[0]=0;
Apellido[0]=0;
Direccion[0]=0;
Telefono[0]=0;
cout<<"Por defecto se inicializa los arrays " <<endl;
};
Persona::Persona(char n[], char *a, char *d, char *t)
{
strcpy(Nombre,n);
strcpy(Apellido,a);
strcpy(Direccion,d);
strcpy(Telefono,t);
};
void Persona::Leer()
{
cout<<"DATOS DE LA PERSONA "<<endl;
cout<<"Nombre: ";
gets(Nombre);
cout<<"Apellidos: ";
gets(Apellido);
cout<<"Direccion: ";
gets(Direccion);
cout<<"Telefono: ";
gets(Telefono);
};
void Persona::Imprimir()
{
cout<<"\nREPORTE DE PERSONA :";
cout<<"\nNombre : "<<Nombre ;
cout<<"\nApellido : "<<Apellido ;
cout<<"\nDireccion: "<<Direccion ;
cout<<"\nTelefono : "<<Telefono ;
};
int main()
{
Estudiante Individuo[10];
int n;
int i;
getch();
clrscr();
cout<<"¨Cuantos datos a evaluar ? ==> ";
cin>>n;
for(i=0;i<n;i++)
Individuo[i].Leer();
getch();
clrscr();
for(i=0;i<n;i++)
Individuo[i].ImprimirDatos();
getch();
return 0;
}
#include<conio.h>
#include<stdio.h>
#include<string.h>
class Persona
{
private:
char Nombre[26];
char Apellido[26];
char Direccion[31];
char Telefono[8];
public:
Persona();
Persona(char n[], char *a, char *d, char *t);
void Leer();
void Imprimir();
};
class Estudiante : public Persona
{
private:
char Univ[20];
char Espe[20];
public:
Estudiante();
void Leer();
void ImprimirDatos();
};
Estudiante::Estudiante(): Persona("X","Y","Z","Z")
{
Univ[0]=0;
Espe[0]=0;
}
void Estudiante::Leer()
{
Persona::Leer();
cout<<"Universidad: ";gets(Univ);
cout<<"Especialidad: ";gets(Espe);
}
void Estudiante::ImprimirDatos()
{
Imprimir();
cout<<"\nUniversidad : "<<Univ;
cout<<"\nEspecialidad: "<<Espe;
}
Persona::Persona()
{
Nombre[0]=0;
Apellido[0]=0;
Direccion[0]=0;
Telefono[0]=0;
cout<<"Por defecto se inicializa los arrays " <<endl;
};
Persona::Persona(char n[], char *a, char *d, char *t)
{
strcpy(Nombre,n);
strcpy(Apellido,a);
strcpy(Direccion,d);
strcpy(Telefono,t);
};
void Persona::Leer()
{
cout<<"DATOS DE LA PERSONA "<<endl;
cout<<"Nombre: ";
gets(Nombre);
cout<<"Apellidos: ";
gets(Apellido);
cout<<"Direccion: ";
gets(Direccion);
cout<<"Telefono: ";
gets(Telefono);
};
void Persona::Imprimir()
{
cout<<"\nREPORTE DE PERSONA :";
cout<<"\nNombre : "<<Nombre ;
cout<<"\nApellido : "<<Apellido ;
cout<<"\nDireccion: "<<Direccion ;
cout<<"\nTelefono : "<<Telefono ;
};
int main()
{
Estudiante Individuo[10];
int n;
int i;
getch();
clrscr();
cout<<"¨Cuantos datos a evaluar ? ==> ";
cin>>n;
for(i=0;i<n;i++)
Individuo[i].Leer();
getch();
clrscr();
for(i=0;i<n;i++)
Individuo[i].ImprimirDatos();
getch();
return 0;
}
Suscribirse a:
Entradas (Atom)