Muchas gracias @PiernaDeFelipeCamiroaga, era lo que me faltaba
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
#include <iostream>
#include <string.h>
using namespace std;
void LeerCadena(string &c)
{
cout << "Ingrese numero: ";
cin >> c;
// para no ingresar se usa la cadena ejemplo
//strcpy(cad,"Sigue las ultimas noticias de #Cuenca, #Ecuador y el Mundo en @eltiempocuenca #marcandodiferencia @IGecuador\0");
}
void Palindrome (string c)
{
string aux;
int j=c.length()-1;
aux=c;
for(int i=0;i<c.length();i++){
if(c[i]!=aux[j]){
break;
}
j--;
}
if (j==-1)
{
printf("\n El numero es palindrome");
}
else
{
printf ("\n El numero no es palindrome");
}
}
int main ()
{
string c;
LeerCadena (c);
Palindrome(c);
}
#include <stdio.h>
typedef struct beta{ float n, m, d;}dat;
typedef dat alfa[3];
double func(dat* x){return x[0].m;}
double ff(alfa x){return x[2].m;}
int main()
{
dat gama[3]={{3,5,4.5},{6,7.0},{23,6.7}};
printf("%.2lf\n",func(gama));//imprime 7.0
printf("%.2lf\n",ff(gama));//imrpime 6.7
return 0;
}
#include <iostream>
#include <string.h>
#include <time.h>
using namespace std;
void inicio();
void primer_error();
void segundo_error();
void tercer_error();
void cuarto_error();
void quinto_error();
void jugar();
void rellenar(string n);
void intentos(int intento);
int main(){
int opcion;
srand(time(NULL));
do{
cout << "1. JUGAR" << endl;
cout << "2. SALIR" << endl;
cin >> opcion;
switch(opcion){
case 1: jugar(); break;
case 2: cout << "HASTA LUEGO" << endl; break;
default: cout << "OPCION INCORRECTA, Intente de nuevo" << endl;
}
}while(opcion!=2);
system("pause");
return 0;
}
void inicio()
{
cout << "**********" << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
}
void primer_error()
{
cout << "**********" << endl;
cout << "* | " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
}
void segundo_error()
{
cout << "**********" << endl;
cout << "* | " << endl;
cout << "* O " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
}
void tercer_error()
{
cout << "**********" << endl;
cout << "* | " << endl;
cout << "* O " << endl;
cout << "* /|\\" << endl;
cout << "* " << endl;
cout << "* " << endl;
cout << "* " << endl;
}
void cuarto_error()
{
cout << "**********" << endl;
cout << "* | " << endl;
cout << "* O " << endl;
cout << "* /|\\" << endl;
cout << "* A " << endl;
cout << "* / \\" << endl;
cout << "* " << endl;
}
void quinto_error()
{
cout << "********** " << endl;
cout << "* | " << endl;
cout << "* O " << endl;
cout << "* /|\\ " << endl;
cout << "* A " << endl;
cout << "* / \\ " << endl;
cout << "* " << endl;
cout << " PERDISTE" << endl;
}
void jugar()
{
int aleatorio;
string a="OSO", b="PAYASO", c="CUADERNO";
aleatorio=rand()%3+1;
switch(aleatorio){
case 1: rellenar(a); break;
case 2: rellenar(b); break;
case 3: rellenar(c); break;
}
}
void rellenar(string n)
{
int contador=0, aux=0, aux2, MAX=n.length();
char letra, contenedor[MAX];
for(int i=0;i<MAX;i++){
contenedor[i]='_';
}
inicio();
while(contador<5){
aux2=0;
for(int j=0;j<MAX;j++){
cout << contenedor[j] << " ";
}
cout << endl;
cout << "Ingrese letra: ";
cin >> letra;
for(int k=0;k<MAX;k++){
if(letra==n[k] && contenedor[k]=='_'){
contenedor[k]=letra;
aux++;
break;
}
else{
aux2++;
}
}
if(aux==MAX){
cout << "GANASTE! La palabra oculta es: " << n << endl;
break;
}
if(aux2==MAX){
contador++;
intentos(contador);
}
}
}
void intentos(int intento)
{
switch(intento){
case 1: primer_error(); break;
case 2: segundo_error(); break;
case 3: tercer_error(); break;
case 4: cuarto_error(); break;
case 5: quinto_error(); break;
}
}
const int DIASSEMANA=7;
main(){
float PROMEDIO, TEMPERATURA; short CONTADOR=0;
for(int i=0;i<DIASSEMANA;i++){switch(i){ case 0: std::cout<<"Lunes : "; std::cin>>TEMPERATURA; if(TEMPERATURA>10.0){PROMEDIO+=TEMPERATURA;CONTADOR++;}; break; ... case 6: std::cout<<"Domingo : "; std::cin>>TEMPERATURA; if(TEMPERATURA>10.0){PROMEDIO+=TEMPERATURA;CONTADOR++;}; break;}}
std::cout<<"PROMEDIO: "<<PROMEDIO/CONTADOR<<" GRADOS FAHRENHEIT"<<std::endl;
}
#include <iostream>
using namespace std;
typedef struct{
int rojo;
int verde;
int azul;
}tpixel;
void crear_pixel(tpixel &color);
bool validar_pixel(tpixel color);
void mostrar_pixel(tpixel color);
void generar_blanco(tpixel color);
void generar_negro(tpixel color);
int main()
{
tpixel p;
crear_pixel(p);
mostrar_pixel(p);
generar_blanco(p);
generar_negro(p);
system("pause");
return 0;
}
void crear_pixel(tpixel &color)
{
do{
cout << "Ingrese rojo : "; cin >> color.rojo;
cout << "Ingrese verde: "; cin >> color.verde;
cout << "Ingrese azul : "; cin >> color.azul;
}while(validar_pixel(color)!=true);
}
bool validar_pixel(tpixel color)
{
if((color.rojo<0 || color.rojo>255) || (color.verde<0 || color.verde>255) || (color.azul<0 || color.azul>255)){
return false;
}
else{
return true;
}
}
void mostrar_pixel(tpixel color)
{
cout << "Rojo : " << color.rojo << endl;
cout << "Verde: " << color.verde << endl;
cout << "Azul : " << color.azul << endl;
}
void generar_blanco(tpixel color)
{
color.rojo=255;
color.verde=255;
color.azul=255;
cout << "Blanco" << endl;
mostrar_pixel(color);
}
void generar_negro(tpixel color)
{
color.rojo=0;
color.verde=0;
color.azul=0;
cout << "Negro" << endl;
mostrar_pixel(color);
}
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
typedef struct{
int rojo;
int azul;
int verde;
}tpixel;
const int x=255, y=255;
void crear_pixel(tpixel &color);
bool validar_pixel(tpixel color);
void mostrar_pixel(tpixel color);
void generar_blanco();
void generar_negro();
int main()
{
tpixel color_pixel;
crear_pixel(color_pixel);
mostrar_pixel(color_pixel);
generar_blanco();
generar_negro();
system("pause");
return 0;
}
void crear_pixel(tpixel &color)
{
do{
cout << "Ingrese rojo : "; cin >> color.rojo;
cout << "Ingrese verde: "; cin >> color.verde;
cout << "Ingrese azul : "; cin >> color.azul;
}while(validar_pixel(color)!=true);
}
bool validar_pixel(tpixel color)
{
if((color.rojo<0 || color.rojo>255) || (color.verde<0 || color.verde>255) || (color.azul<0 || color.azul>255)){
return false;
}
else{
return true;
}
}
void mostrar_pixel(tpixel color)
{
cout << "Rojo : " << color.rojo << endl;
cout << "Verde: " << color.verde << endl;
cout << "Azul : " << color.azul << endl;
}
void generar_blanco()
{
ofstream img("picture.ppm");
img << "P3" << endl;
img << x << " " << y << endl;
img << "255" << endl;
for(int i=0; i<x; i++){
for(int k=0; k<y; k++){
int r=x%255;
int g=y%255;
int b=y*x%255;
img << r << " " << g << " " << b << endl;
}
}
system("open picture.ppm");
}
void generar_negro()
{
}
#include <iostream>
using namespace std;
bool primo(int n);
int main()
{
int v_inicial, v_final;
cout << "Ingrese valor inicial: "; cin >> v_inicial;
cout << "Ingrese valor final : "; cin >> v_final;
while(v_inicial<=v_final){
if(primo(v_inicial)==true){
cout << v_inicial << " ";
}
v_inicial++;
}
cout << endl;
system("pause");
return 0;
}
bool primo(int n)
{
int i=1, cont=0;
while(i<=n){
if(n%i==0){
cont++;
}
i++;
}
if(cont==2){
return true;
}
else{
return false;
}
}
#include <iostream>
#include <string.h>
using namespace std;
const int MAX=10;
typedef char tarreglo[MAX];
void cargar_arreglo(tarreglo &n, int &ocupado);
void mostrar_arreglo(tarreglo n, int ocupado);
void calcular_parejas(tarreglo n, int ocupado);
int main()
{
tarreglo palabra;
int lleno=0;
cargar_arreglo(palabra, lleno);
mostrar_arreglo(palabra, lleno);
calcular_parejas(palabra, lleno);
system("pause");
return 0;
}
void cargar_arreglo(tarreglo &n, int &ocupado)
{
for(int i=0; i<MAX; i++){
cout << "Ingrese caracter(0 para finalizar): ";
cin >> n[i];
if(n[i]=='0'){
break;
}
ocupado++;
}
}
void mostrar_arreglo(tarreglo n, int ocupado)
{
for(int i=0; i<ocupado; i++){
cout << n[i];
}
cout << endl;
}
void calcular_parejas(tarreglo n, int ocupado)
{
int parejas=0;
for(int i=0; i<ocupado; i++){
if(n[i]==n[i+1]){
parejas++;
i++;
}
}
cout << "Parejas: " << parejas << endl;
}
#include <iostream>
using namespace std;
const int FILA=4, COLUMNA=4;
typedef int matriz[FILA][COLUMNA];
void cargar_matriz(matriz &n);
void mostrar_matriz(matriz n);
void sumar_contenido(matriz n);
int main()
{
matriz mi_matriz;
cargar_matriz(mi_matriz);
mostrar_matriz(mi_matriz);
sumar_contenido(mi_matriz);
system("pause");
return 0;
}
void cargar_matriz(matriz &n)
{
for(int i=0; i<FILA; i++){
for(int k=0; k<COLUMNA; k++){
cout << "Ingrese elemento posicion[" << i << "][" << k << "]:";
cin >> n[i][k];
}
}
}
void mostrar_matriz(matriz n)
{
for(int i=0; i<FILA; i++){
for(int k=0; k<COLUMNA; k++){
cout << "[" << n[i][k] << "]";
}
cout << endl;
}
}
void sumar_contenido(matriz n)
{
int suma=0;
for(int i=0; i<FILA; i++){
for(int k=0; k<COLUMNA; k++){
suma+=n[i][k];
}
}
cout << "Suma: " << suma << endl;
}