Académique Documents
Professionnel Documents
Culture Documents
Hallar A+B-C+100
Código:
#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)
Código:
#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();
}
En línea
[www.darvein.net]
int main ()
{
int n, serie=2, suma=0;
=) printf ("Inserte cantidad de terminos a generar:
"); scanf ("%d",&n);
for (int i=1;i<=n;i++)
{
printf ("%d! + ",serie);
suma=suma+(facto(serie));
serie=serie+2;
}
printf (" = %d",suma);
getch();
}
int main ()
{
int serie=1;
bool sw=true;
do
{
printf("%d, ",serie);
if (sw) serie+=4;
else serie-=2;
sw=!sw;
} while (serie<=23);
getch();
}
Generar 5,10,15,20,25,30,35....n
Código:
#include<stdio.h>
#include<conio.h>
int main ()
{
int n, c=1, serie=5;
printf("Cantidad de terminos: ");
scanf("%d",&n);
while(c<=n)
{
printf("%d,",serie);
serie+=5; c++;
}
getch();
}
Si n=7 generar 7,6,5,4,3,2,1
Código:
#include<stdio.h>
#include<conio.h>
int main ()
{
int n, c=1;
printf("Cantidad de terminos: ");
scanf("%d",&n);
int serie=n;
while(c<=n)
{
printf("%d,",serie);
serie--; c++;
}
getch();
}
En línea
[www.darvein.net]
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();
}
int main ()
{
int V[20];
int d, x;
printf("Inserte dimen. del vector: ");
scanf("%d",&d);
printf ("Inserte valor de (x): ");
scanf("%d",&x);
llenar (V, d);
printf("\nVECTOR: ");
mostrar (V, d);
evalua (V, d, x);
getch();
}
En línea
[www.darvein.net]
Generar la matriz:
[01][02][03][04]
[08][07][06][05]
[09][10][11][12]
Código:
#include<stdio.h>
#include<conio.h>
void llenar (int M[20][20], int f, int c)
=) {
int k=1;
for (int i=1;i<=f;i++)
{
if (i%2!=0)
{
for (int j=1;j<=c;j++)
{
M[i][j]=k; k++;
}
}
else
{
for (int j=c;j>=1;j--)
{
M[i][j]=k; k++;
}
}
}
}
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]
Código:
#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;
}
}
}
int main ()
{
int d;
int M[20][20];
printf("Insert dimen: "); scanf("%d",&d);
llenar(M, d);
mostrar(M, d);
getch();
}
int main ()
{
int A [20] [20];
int B [20] [20];
int fa, ca, fb, cb;
printf ("Insert filas de A: "); scanf("%d",&fa);
printf ("Insert columnas de A: "); scanf("%d",&ca);
printf ("Insert filas de B: "); scanf("%d",&fb);
printf ("Insert columnas de B: "); scanf("%d",&cb);
//lectura de matrices
printf ("\nINSERTANDO DATOS EN MATRIS A: \n");
llenar (A, fa, ca);
printf ("\nINSERTANDO DATOS EN MATRIS B: \n");
llenar (B, fb, cb);
printf ("\nMATRICES ORIGINALMENTE INSERTADAS: ");
mostrar (A, fa, ca);
printf ("\n");
mostrar (B, fb, cb);
printf ("\n");
//intercambiando elementos
intercambiar (A, fa, ca, B, fb, cb);
printf ("\nMATRICES DESPUES DEL INTERCAMBIO:");
mostrar (A, fa, ca);
printf ("\n");
mostrar (B, fb, cb);
getch();
}
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();
}
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 SECUNDARIA
INVERTIDA: ");
invierte (M, d);
mostrar (M, d);
getch();
}
int main()
{
int R [20] [20];
int S [20] [20];
int fr, cr, fs, cs;
printf("Inserte filas de R: ");
scanf("%d",&fr);
printf("Inserte columnas de R: ");
scanf("%d",&cr);
printf("Inserte filas de S: ");
scanf("%d",&fs);
printf("Inserte columnas de S: ");
scanf("%d",&cs);
printf("\nLLENANDO MATRIS R: \n");
llenar (R, fr, cr);
printf("\nLLENANDO MATRIS S: \n");
llenar (S, fs, cs);
printf("\nLA MATRIS R : ");
mostrar (R, fr, cr);
printf("\n\nLA MATRIS S : ");
mostrar (S, fs, cs);
comunes (R, fr, cr, S, fs, cs);
getch();
}
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);
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);
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);
[www.darvein.net]
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);
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);
int main ()
{
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);
http://foro.elhacker.net/ejercicios/ejercicios_resueltos_c_programacion_estructurada-
t201980.0.html#ixzz1MvlR5Qcq