Mostrar Los Multiplos de 3 Comprendidos Entre Los Numeros 1 y 20
Mostrar Los Multiplos de 3 Comprendidos Entre Los Numeros 1 y 20
Cdigo:
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
int main ()
{
clrscr();
for (int i=1;i<=20;i++)
{
cout<<i;
if (i%3==0) cout<<" Es multiplo de 3" <<endl;
else cout<<" No es multiplo de 3"<<endl;
}
getch();
return 0;
}
Hallar A+B-C+100
Cdigo:
#include <stdio.h>
#include <conio.h.>
int main ()
{
int A, B, C;
printf("Inserte valor para A: "); scanf("%d",&A);
printf("Inserte valor para B: "); scanf("%d",&B);
printf("Inserte valor para C: "); scanf("%d",&C);
printf("\n%d + %d - %d + 100 = %d",A, B, C, (A+B+C-100));
getch();
}
Obtener (a-b)(a+b)
Cdigo:
#include <stdio.h>
#include <conio.h>
int main ()
{
int a, b;
printf("Inserte valor a: "); scanf("%d",&a);
printf("Inserte valor b: "); scanf("%d",&b);
printf("(%d-%d) (%d+%d) = %d",a, b, a, b,((a-b)*(a+b)));
getch();
}
pares
Cdigo:
#include<stdio.h>
#include<conio.h>
int main()
{
int a, b, c, d, e, f;
printf("Inserte num.1: "); scanf("%d",&a);
printf("Inserte num.2: "); scanf("%d",&b);
printf("Inserte num.3: "); scanf("%d",&c);
printf("Inserte num.4: "); scanf("%d",&d);
printf("Inserte num.5: "); scanf("%d",&e);
printf("Inserte num.6: "); scanf("%d",&f);
int menor=a;
if(b<menor) menor=b;
if(c<menor) menor=c;
if(d<menor) menor=d;
if(e<menor) menor=e;
if(f<menor) menor=f;
printf("El menor de %d,%d,%d,%d,%d,%d ",a,b,c,d,e,f);
printf("\nEs %d",menor);
getch();
}
En lnea
Ilusin o realidad?
Darvein
Desconectado
Mensajes: 182
{
printf ("%d! + ",serie);
suma=suma+(facto(serie));
serie=serie+2;
}
printf ("
getch();
= %d",suma);
serie--; c++;
}
getch();
}
En lnea
Ilusin o realidad?
Darvein
Desconectado
Mensajes: 182
fin1 = d;
for (int j = (d / 2) + 1 ; j <= (d / 2) + 1 ;
j++)
{
aux1 = V [j];
V [j] = V [fin1];
V [fin1] = aux1;
fin1--;
}
}
int main ()
{
int V[20];
int d;
printf ("Inserte dimen. del vector: ");
scanf("%d",&d);
llenar (V, d);
printf ("\nVECTOR ORIGINAL: \n");
mostrar (V, d);
printf ("\n\nVECTOR LUEGO DE LA INVERSION:
\n");
invierte (V, d);
mostrar (V, d);
getch();
}
/*Dado un polinomio evualuarlo en el punto x
(todo en un vector)*/
Cdigo:
#include <stdio.h>
#include <conio.h>
void llenar (int V[20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf ("Inserte pos.[%d]: ",i);
scanf("%d",&V[i]);
}
}
void mostrar (int V[20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf ("[%d]",V[i]);
}
}
int potencia (int b, int e)
{
int p = 1;
for (int i = 1 ; i <= e ; i++)
{
p = p * b;
}
return (p);
}
M[i][j]=k; k++;
}
}
}
}
void mostrar (int M[20][20], int f, int c)
{
for (int i=1;i<=f;i++)
{
printf("\n");
for (int j=1;j<=c;j++)
{
printf("[%d] ",M[i][j]);
}
}
}
int main ()
{
int f, c;
int M[20][20];
printf("Inserte filas de M: ");
scanf("%d",&f);
printf("Inserte cols. de M: ");
scanf("%d",&c);
llenar(M, f, c);
mostrar(M, f, c);
getch();
}
Generar la matriz:
[01][02][03][04]
[05][06][07][00]
[08][09][00][00]
[10][00][00][00]
Cdigo:
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
int cont=1;
for (int i=1;i<=d;i++)
{
for (int j=1;j<=d;j++)
{
if ((i+j)<=(d+1))
{M[i][j]=cont; cont++;}
else
M[i][j]=0;
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i=1;i<=d;i++)
{
printf("\n");
A: ");
de A: ");
B: ");
de B: ");
//lectura de matrices
printf ("\nINSERTANDO DATOS EN MATRIS A: \n");
llenar (A, fa, ca);
printf ("\nINSERTANDO DATOS EN MATRIS B: \n");
int main()
{
int M [20] [20];
int d;
printf ("Inserte dimen. de la matris cuadrada:
");
scanf("%d",&d);
llenar (M, d);
printf ("\nMATRIS ORIGINAL: ");
mostrar (M, d);
printf ("\n\nMATRIS CON LA DIAGONAL PRINCIPAL
INVERTIDA: ");
invierte (M, d);
mostrar (M, d);
getch();
}
/*Dada una matris cuadrada invertir su diagonal
secundaria*/
Cdigo:
#include <stdio.h>
#include <conio.h>
void llenar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
for (int j = 1 ; j <= d ; j++)
{
printf ("Inserte pos[%d][%d]: ",i, j);
scanf("%d",&M [i] [j]);
}
}
}
void mostrar (int M[20][20], int d)
{
for (int i = 1 ; i <= d ; i++)
{
printf("\n");
for (int j = 1 ; j <= d ; j++)
{
printf ("[%d]",M [i] [j]);
}
}
}
void invierte
{
int fin = d;
for (int i =
{
int aux = M
M [i] [d] =
M [d] [i] =
fin--;
}
}
int main()
{
}
}
}
}
}
int main()
{
int R [20] [20];
int S [20] [20];
int fr, cr, fs, cs;
printf("Inserte filas de
scanf("%d",&fr);
printf("Inserte columnas
scanf("%d",&cr);
printf("Inserte filas de
scanf("%d",&fs);
printf("Inserte columnas
scanf("%d",&cs);
R: ");
de R: ");
S: ");
de S: ");
}
}
void intercambiar (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
int aux = M [i] [1];
M [i] [1] = M [i] [c];
M [i] [c] = aux;
}
}
int main ()
{
int M [20] [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS : \n");
llenar (M, f, c);
printf ("\nLA MATRIS ORIGINAL : ");
mostrar (M, f, c);
printf ("\n\nLA MATRICES INTERCAMBIADA : ");
intercambiar (M, f, c);
mostrar (M, f, c);
getch();
}
}
}
void cuenta (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
int contador = 0;
int n=M[i][j];
while (n != 0)
{
n = n / 10;
contador++;
}
printf("\n[%d] tiene: %d
digito(s)",M[i][j],contador);
}
}
}
int main ()
{
int M [20] [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS M: \n");
llenar (M, f, c);
printf ("\nLA MATRIS: ");
mostrar (M, f, c);
printf ("\n\nCONTEO DE DIGITOS: ");
cuenta (M, f, c);
getch();
}
c)
{
for (int i = 1 ; i <= f ; i++)
{
printf ("\n");
for (int j = 1 ; j <= c ; j++)
{
printf ("[%d]",M [i] [j] );
}
}
}
void busqueda (int M[20][20], int f, int c, int
e)
{
int bn = 0;
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
if (M [i] [j] == e)
{
printf("\nEl numero: %d se encuentra en la
posicion: [%d][%d] de la matris",e, i, j);
bn = 1;
}
}
}
if (bn == 0)
printf("\nNo se encontro el numero %d en la
matris :(",e);
}
int main ()
{
int M [20] [20];
int f, c, numero;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS: \n");
llenarMatris (M, f, c);
printf ("\nLA MATRIZ Z: ");
mostrarMatris (M, f, c);
printf ("\n\nInserte un numero: ");
scanf("%d",&numero);
busqueda (M, f, c, numero);
getch();
}
En lnea
Ilusin o realidad?
Darvein
Desconectado
Mensajes: 182
int cc = 0;
for (int k = 1 ; k <= M [i] [j] ; k++)
{
if (M [i] [j] % k == 0)
cc++;
}
if (cc == 2)
cant++;
}
}
return (cant);
}
int primosVector (int V[20], int d)
{
int cant = 0;
for (int i = 1 ; i <= d ; i++)
{
int c = 0;
for (int j = 1 ; j <= V [i] ; j++)
{
if (V [i] % j == 0)
c++;
}
if (c == 2)
cant++;
}
return (cant);
}
int main()
{
int M [20] [20];
int V [20];
int f, c, d;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("Inserte dimension del vector: ");
scanf("%d",&d);
printf ("\nLLENANDO MATRIS: \n");
llenarMatris (M, f, c);
printf ("\nLLENANDO EL VECTOR: \n");
llenarVector (V, d);
printf ("\nLA MATRIS: ");
mostrarMatris (M, f, c);
printf ("\n\nEL VECTOR: \n");
mostrarVector (V, d);
int primos = primosMatris (M, f, c) +
primosVector (V, d);
printf ("\n\nLA CANTIDAD DE NUMEROS PRIMOS QUE
HAY EN LOS ARREGLOS ES: %d",primos);
getch();
int main ()
{
int M [20] [20];
int V [20];
int f, d;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte dimension del vector: ");
scanf("%d",&d);
printf ("\nLLENANDO MATRIS: \n");
llenarMatris (M, f, d);
printf ("\nLLENANDO EL VECTOR: \n");
llenarVector (V, d);
printf ("\nLA MATRIS: ");
mostrarMatris (M, f, d);
printf ("\n\nEL VECTOR: \n");
mostrarVector (V, d);
procedure (M, f, d, V, d);
getch();
}
/*Dada una matris Z almacenar en un vector A la
suma por sus columnas
y en un vector B la suma por sus filas */
Cdigo:
#include <stdio.h>
#include <conio.h>
void llenarMatris (int M[20][20], int f, int c)
{
for (int i = 1 ; i <= f ; i++)
{
for (int j = 1 ; j <= c ; j++)
{
printf ("Inserte pos[%d][%d]: ",i,j);
scanf("%d",&M [i] [j]);
}
}
}
{
int Z [20] [20];
int A [20];
int B [20];
int f, c;
printf ("Inserte filas de la matris: ");
scanf("%d",&f);
printf ("Inserte columnas de la matris: ");
scanf("%d",&c);
printf ("\nLLENANDO MATRIS: \n");
llenarMatris (Z, f, c);
printf ("\nLA MATRIZ Z: ");
mostrarMatris (Z, f, c);
printf ("\n\nSUMA
(vector A): \n");
vectorA (Z, f, c,
mostrarVector (A,
printf ("\n\nSUMA
(vector B): \n");
vectorB (Z, f, c,
mostrarVector (B,
getch();
}