(2024)
Sin respuestas :c
(2024)
#include <stdio.h>
#include <stdlib.h>
int suma(int a,int b,int c){
return a+b+c;
}
int producto(int a,int b,int c){
return a*b*c;
}
void main(){
int *a,*b,*c;
a = (int *)malloc(sizeof(int));
b = (int *)malloc(sizeof(int));
c = (int *)malloc(sizeof(int));
*a = *b = *c = 70;
printf("La suma es %d y el producto %d",suma(*a,*b,*c),producto(*a,*b,*c));
free(a); free(b); free(c);
}
#include <stdio.h>
#include <stdlib.h>
void main(){
int N, *V;
printf("Ingrese cantidadd de datos: ");
scanf("%d",&N);
V = (int*)malloc(N*sizeof(int));
for(int i = 0;i<N;i++){
printf("Ingresar numero %d: ",i+1);
scanf("%d",V+i);
};
printf("Los numeros positivos son:\n");
for(int j=0;j<N;j++){
if(*(V+j)>0){
printf(" %d^ %d\n",j+1,*(V+j));
}
};
free(V);
}
#include <stdio.h>
#include <stdlib.h>
#define N 100
int main()
{
int *v[N];
FILE *arch;
int cantNum;
arch = fopen("numeros.txt","r");
//guarda enteros en el arreglo
if (arch == NULL) printf("El archivo no se encuentra\n");
else {
cantNum = 0;
while(!feof(arch) && cantNum < N){
v[cantNum]=(int *)malloc(sizeof(int));
fscanf(arch,"%d",v[cantNum]);
cantNum++;
};
};
//muestra numeros positivos
for(int j=0;j<cantNum;j++){
int num = *v[j];
if (num>0) printf("%d en posicion %d\n",num,j+1);
};
//libera memoria
for(int k=0;k<cantNum;k++){
free(v[k]);
}
fclose(arch);
return 0;
}
(2024)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 5
int producto(int a,int b){
if(b==0 || a==0){
return 0;
}
else{
return a + producto(a,b-1);
}
}
int cociente(int a,int b){
if(a<b){
return 0;
}
else {
return 1 + cociente(a-b,b);
}
}
int resto(int a,int b){
if(a<b){
return b-a;
}
else{
return resto(a-b,b);
}
}
int maximo(int arr[], int n) {
if (n == 1) {
return arr[0];
} else {
int m = maximo(arr, n - 1);
return (arr[n - 1] > m) ? arr[n - 1] : m;
}
}
int main()
{
int v[N] = {2,5,2,6,5};
int a,b;
do {
printf("Ingresar numeros a multiplicar: ");
scanf("%d %d",&a,&b);
if(a<0 || b<0){
printf("Los numeros tienen que ser mayores a 0\n");
}
} while(a<0 || b<0);
printf("El producto entre ambos numeros es: %d\n",producto(a,b));
printf("El cociente de la division de ambos numeros es: %d\n",cociente(a,b));
printf("El resto de la division de ambos numeros es: %d\n",resto(a,b));
printf("VOID - El maximo del vector v es:\n");
printf("INT - El maximo del vector v es: %d\n",maximo(v,N));
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define Nv 5
#define filas 2
int sumaV(int v[],int n){
if(n==0){
return v[0];
}
else {
return v[n] + sumaV(v,n-1);
}
}
void mostrarElementos(int v[],int n){
if(n==0){
printf("Elemento 1: %d\n", v[0]);
return 0;
}
else{
printf("Elemento %d: %d\n",n+1,v[n]);
mostrarElementos(v,n-1);
}
}
void mostrarElementosInversos(int v[],int i,int n){
if(i==n){
printf("Elemento %d: %d\n",i+1,v[i]);
}
else{
printf("Elemento %d: %d\n",i+1,v[i]);
mostrarElementosInversos(v,i+1,n);
}
}
int posDesordenado(float v[],int n,float x){
if(n==0){
return v[0]==x ? 0 : -1;
}
else{
return v[n]==x ? n : posDesordenado(v,n-1,x);
}
}
int posOrdenado(float v[],int i,int n,float x){
int pos = (n-i)/2+i;
if(v[pos]==x){
return pos;
}
else{
if(i==n){
return -1;
}
else{
if(v[pos]>x){
return posOrdenado(v,i,pos,x);
}
else{
return posOrdenado(v,pos+1,n,x);
}
}
}
}
int minimoM(int M[][Nv],int i,int j,int n){
if (i<0){
return M[0][0];
}
else{
if(j<0){
return minimoM(M,i-1,n,n);
}
else{
int min = minimoM(M,i,j-1,n);
return min < M[i][j] ? min : M[i][j];
}
}
}
void inicializarV(int V[],int n){
for(int i=0;i<n;i++){
V[i] = 0;
}
}
void maximosFilas(int M[][Nv],int i,int j,int m,int n,int *V){
if(i<0){
V[0] = M[0][0];
}
else{
if(j<0){
maximosFilas(M,i-1,n,m,n,V);
}
else{
maximosFilas(M,i,j-1,m,n,V);
V[i] < M[i][j] ? V[i]=M[i][j] : NULL;
}
}
}
void mezclarArreglos(int A[],int n, int B[], int m,int C[]){
if(n==0 && m==0){
return 0;
}
else{
if(n==0){
C[0] = B[0];
mezclarArreglos(A,n,B+1,m-1,C+1);
return 0;
}
else{
if(m==0){
C[0] = A[0];
mezclarArreglos(A+1,n-1,B,m,C+1);
return 0;
}
if(A[0]>B[0]){
C[0] = B[0];
mezclarArreglos(A,n,B+1,m-1,C+1);
return 0;
}
else{
if(A[0]<B[0]){
C[0] = A[0];
mezclarArreglos(A+1,n-1,B,m,C+1);
return 0;
}
else{
C[0] = A[0];
mezclarArreglos(A+1,n-1,B+1,m-1,C+1);
return 0;
}
}
}
}
}
int main()
{
printf("\tINCISO A\n");
int v[Nv] = {1,2,3,4,5};
printf("La suma de sus elementos es: %d\n",sumaV(v,Nv-1));
mostrarElementos(v,Nv-1);
mostrarElementosInversos(v,0,Nv-1);
float a[Nv] = {1.3,1.4,2.5,3.4,3.6};
float X;
printf("\tINCISO B\n");
printf("Ingresar X: ");scanf("%f",&X);
int posOrd = posDesordenado(a,Nv-1,X);
posOrd==-1 ? printf("El valor X no se encuentra en el arreglo\n") : printf("El valor X se encuentra en la posicion %d\n",posOrd);
int posDesord = posOrdenado(a,0,Nv-1,X);
posDesord==-1 ? printf("El valor de X no se encuentra en el arreglo\n") : printf("El valor X se esncuentra en la posicion %d\n",posDesord);
printf("\tINCISO C\n");
int M[][Nv] = {{10,2,3,4,5},
{10,2,3,4,5},
{10,2,3,4,5},
{10,2,3,1,5},
{10,2,3,4,5}};
printf("El elemento minimo es: %d\n",minimoM(M,Nv-1,Nv-1,Nv-1));
printf("\tINCISO D\n");
int vMax[filas];
inicializarV(vMax,filas);
int M2[][Nv] = {{10,2,3,42,5},
{15,2,30,4,5}};
maximosFilas(M2,filas-1,Nv-1,filas-1,Nv-1,vMax);
printf("\tFilas\tMaximos\n");
for(int i=0;i<filas;i++){
printf("\t%d \t%d\n",i+1,vMax[i]);
};
printf("\tINCISO E\n");
int arregloA[] = {2,3,6,8,12};
int arregloB[] = {3,5,7,11,13,15};
int arregloC[30];
mezclarArreglos(arregloA,sizeof(arregloA)/sizeof(int),arregloB,sizeof(arregloB)/sizeof(int),arregloC);
mostrarElementosInversos(arregloC,0,(sizeof(arregloA)+sizeof(arregloB))/sizeof(int)-1);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define N 10
float promedioV(float v[],int i,int n){
if(n==i){
return v[n];
}
else{
if(i==0){
return (promedioV(v,i+1,n) + v[i])/(n+1);
}
else{
return promedioV(v,i+1,n)+v[i];
}
}
}
int main()
{
float v[N] = {1,4,3,5,6,2,7,6,4,23};
printf("El promedio de sus elementos es: %f\n",promedioV(v,0,N-1));
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define N 2
#define M 3
void cantidadVoid(float Ma[][M],int i,int j,int n,int m,float x,int *cant){
if(i<0){
return 0;
}
else{
if(j<0){
cantidadVoid(Ma,i-1,m,n,m,x,cant);
return 0;
}
else{
Ma[i][j]==x ? ++*cant : NULL;
cantidadVoid(Ma,i,j-1,n,m,x,cant);
return 0;
}
}
}
int main()
{
float Ma[N][M]={{3.4,4.5,2.1},
{2.6,4.5,4.5}};
float x;
int cant = 0;
printf("Ingresar numero a buscar: "); scanf("%f",&x);
cantidadVoid(Ma,N-1,M-1,N-1,M-1,x,&cant);
cant>0 ? printf("%f se repite %d veces\n",x,cant) : printf("%f no aparece en la matriz\n",x);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define N 3
int esSimetrica(int Ma[][N],int i,int j,int n){
if(i<0){
return 1;
}
else{
if(j<0){
return esSimetrica(Ma,i-1,n-1,n-1);
}
else{
return Ma[i][j]==Ma[j][i] ? 1*esSimetrica(Ma,i,j-1,n) : 0;
}
}
}
int main()
{
int Ma[N][N] = {{1,2,3},
{2,1,4},
{3,4,1}};
esSimetrica(Ma,N-1,N-1,N-1)==1 ? printf("Es simetrica") : printf("No es simetrica");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#define N 4
#define M 3
int sumaFila(int Matriz[N][M],int i,int j){
if(j==0) return Matriz[i][j];
else {
return Matriz[i][j] + sumaFila(Matriz,i,j-1);
};
}
int cumple(int Matriz[N][M],int i,int j){
if (i==0) return sumaFila(Matriz,i,j)%2 == 0 ? 1 : 0;
else {
if (sumaFila(Matriz,i,j) > sumaFila(Matriz,i-1,j)) return cumple(Matriz,i-1,j);
else return 0;
}
}
int main()
{
int Matriz[N][M] = {{1,3,2},
{4,1,4},
{2,5,6},
{3,6,5}};
cumple(Matriz,N-1,M-1) ? printf("Cumple con lo pedido\n") : printf("No cumple");
return 0;
}
(2024)
Sin respuestas :c
(2024)
Sin respuestas :c
(2024)
Sin respuestas :c
(2024)
Sin respuestas :c
(2024)
Sin respuestas :c