|
Mostrar Mensajes
|
Páginas: [1]
|
1
|
Programación / Programación C/C++ / matriz imprime basura
|
en: 19 Febrero 2017, 04:57 am
|
ayuda por favor no se por que la matriz me imprime lo que debe de ser pero tambien me imprime basura soy nuevo en esto de programacion por favor ayuda #include<stdio.h> #include<stdlib.h> #include<math.h> void LeerInt(int*,int*,int*,int*,char*); void M1(int*,int*,int*,int,char*); int main(){ int x[50]; int x2[50]; int x1[50]; int d[50]; int n; LeerInt(x,x1,x2,&n,"NUMERO"); M1(x,x1,x2,n,"NUMERO"); return 0; } void LeerInt(int *x,int*x1,int*x2,int *m,char*nom){ int i; int matriz[100][100]; printf("\n\t elementos del vector son: "); for(i=0;i<*m;i++){ printf("\n\t INGRESE Los elementos del primer vector %s[%i]:", nom ,i +1); } for(i=0;i<*m;i++){ printf("\n\t INGRESE Los elementos del segundo vector %s[%i]:", nom ,i +1); } for(i=0;i<*m;i++){ printf("\n\t INGRESE Los elementos del tercer vector %s[%i]:", nom ,i +1); } } void M1(int*x,int*x1,int*x2,int m,char*nom){ int t,j,k=0,z=0,i=0,l; int matriz[100][100]; for(t=0;t<m;t++) for(j=0;j<3;j++) { matriz[t][j]=x[k];k++; } for(t=0;t<m;t++) for(j=0;j<3;j++) printf("[%d]\n",matriz [t ][j ]); for(t=0;t<m;t++) for(j=0;j<3;j++) { matriz[t][j]=x1[z];z++; } for(t=0;t<m;t++) for(j=0;j<3;j++) printf("[%d]\n",matriz [t ][j ]); for(t=0;t<m;t++) for(j=0;j<3;j++) { matriz[t][j]=x2[i];i++; } for(t=0;t<m;t++) for(j=0;j<3;j++) printf("[%d]\n",matriz [t ][j ]); return;}
|
|
|
2
|
Programación / Programación C/C++ / ayuda con multiplicacion de n numeros complejos
|
en: 27 Noviembre 2016, 15:58 pm
|
hola, el programa tiene que sumar,restar y multiplicar n numeros complejos, la suma y la resta ya la tengo pero en la multiplicacion estoy atorado no tengo una idea clara de como hacerlo me podrían ayudar porfavor #include<stdio.h> #include<stdlib.h> void LeerInt(int*, int*,int*,char*); void ImprInt(int*,int*,int,char*); int suma(int*,int*,int); int resta(int*,int*,int); int multiplicacion(int*,int*,int); int main(){ int x[50]; int d[50]; int n; LeerInt(x,d,&n,"NUMERO"); ImprInt(x,d,n,"NUMERO"); suma(x,d,n); resta(x,d,n); multiplicacion(x,d,n); return 0; } void LeerInt(int *x,int *d,int *m,char*nom){ int i; printf("\n\t CUANTOS NUMEROS COMPLEJOS SON: "); for(i=0;i<*m;i++){ printf("\n\t INGRESE LA PARTE REAL DEL %s[%i]:", nom ,i +1); } for(i=0;i<*m;i++){ printf("\n\t INGRESE LA PARTE IMAGINARIA DEL %s[%i]:", nom ,i +1); return; } void ImprInt(int*y,int*t,int m,char*nom){ int i; printf("\n\t LOS DATOS SON:"); for(i=0;i<m;i++){ printf("\n\t LOS NUMEROS COMPLEJOS SON: %s[%i]=%d + %ij",nom ,i +1,y [i ],t [i ]);} return;} int suma (int *x,int *d, int m){ int i; int s=0.0,f=0.0; for(i=0;i<m;i++){ s+= x[i];} for(i=0;i<m;i++){ f+= d[i];} printf("\n\t LA SUMA DE LOS NUMEROS ES %i+ %i j",s ,f ); return; } int resta (int *x,int *d, int m){ int i; int s=x[0],f=d[0]; for(i=1;i<m;i++){ s = s-x[i];} for(i=1;i<m;i++){ f = f-d[i];} if (f>=0){ printf("\n\t LA RESTA DE LOS NUMEROS ES %i + %i j",s ,f ); } else { printf("\n\t LA RESTA DE LOS NUMEROS ES %i%ij",s ,f ); } return; } int multiplicacion(int*x,int*d,int m){ int i,r=1,c=1,v=1; for(i=0;i<m;i++){ r= r*x[i];} // multiplicacion de reales for(i=0;i<m;i++){ c= c*d[i];} //multiplicacion de imaginarios for(i=0;i<m;i++){ v=v*x[i]*d[i];} }
|
|
|
|
|
|
|