elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


  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 :(

Código
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4.  
  5. void LeerInt(int*,int*,int*,int*,char*);
  6. void M1(int*,int*,int*,int,char*);
  7.  
  8. int main(){
  9. int x[50];
  10. int x2[50];
  11. int x1[50];
  12. int d[50];
  13. int n;
  14. LeerInt(x,x1,x2,&n,"NUMERO");
  15. M1(x,x1,x2,n,"NUMERO");
  16.  
  17.  
  18. return 0;
  19. }
  20.  
  21. void LeerInt(int *x,int*x1,int*x2,int *m,char*nom){
  22. int i;
  23. int matriz[100][100];
  24. printf("\n\t elementos del  vector son: ");
  25. scanf("%i",m);
  26. for(i=0;i<*m;i++){
  27. printf("\n\t  INGRESE Los elementos del primer vector %s[%i]:", nom,i+1);
  28. scanf("%d",&x[i]);
  29. }
  30. for(i=0;i<*m;i++){
  31. printf("\n\t  INGRESE Los elementos del segundo vector %s[%i]:", nom,i+1);
  32. scanf("%d", &x1[i]);
  33. }
  34. for(i=0;i<*m;i++){
  35. printf("\n\t  INGRESE Los elementos del tercer vector %s[%i]:", nom,i+1);
  36. scanf("%d", &x2[i]);
  37. }
  38. }
  39.  
  40. void M1(int*x,int*x1,int*x2,int m,char*nom){
  41.    int t,j,k=0,z=0,i=0,l;
  42. int matriz[100][100];
  43.  
  44. for(t=0;t<m;t++)
  45. for(j=0;j<3;j++)
  46. {
  47. matriz[t][j]=x[k];k++;
  48. }
  49. for(t=0;t<m;t++)
  50. for(j=0;j<3;j++)
  51. printf("[%d]\n",matriz[t][j]);
  52.  
  53. for(t=0;t<m;t++)
  54. for(j=0;j<3;j++)
  55. {
  56. matriz[t][j]=x1[z];z++;
  57. }
  58. for(t=0;t<m;t++)
  59. for(j=0;j<3;j++)
  60. printf("[%d]\n",matriz[t][j]);
  61.  
  62. for(t=0;t<m;t++)
  63. for(j=0;j<3;j++)
  64. {
  65. matriz[t][j]=x2[i];i++;
  66. }
  67. for(t=0;t<m;t++)
  68. for(j=0;j<3;j++)
  69. printf("[%d]\n",matriz[t][j]);
  70. return;}
  71.  
  72.  
  73.  
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
Código
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. void LeerInt(int*, int*,int*,char*);
  5. void ImprInt(int*,int*,int,char*);
  6. int suma(int*,int*,int);
  7. int resta(int*,int*,int);
  8. int multiplicacion(int*,int*,int);
  9. int main(){
  10. int x[50];
  11. int d[50];
  12. int n;
  13. LeerInt(x,d,&n,"NUMERO");
  14. ImprInt(x,d,n,"NUMERO");
  15. suma(x,d,n);
  16. resta(x,d,n);
  17. multiplicacion(x,d,n);
  18. return 0;
  19. }
  20. void LeerInt(int *x,int *d,int *m,char*nom){
  21. int i;
  22. printf("\n\t CUANTOS NUMEROS COMPLEJOS SON: ");
  23. scanf("%i",m);
  24. for(i=0;i<*m;i++){
  25. printf("\n\t  INGRESE LA PARTE REAL DEL %s[%i]:", nom,i+1);
  26. scanf("%d", &x[i]);
  27. }
  28. for(i=0;i<*m;i++){
  29. printf("\n\t  INGRESE LA PARTE IMAGINARIA DEL %s[%i]:", nom,i+1);
  30. scanf("%d", &d[i]);}
  31. return;
  32. }
  33.  
  34. void ImprInt(int*y,int*t,int m,char*nom){
  35. int i;
  36. printf("\n\t LOS DATOS SON:");
  37. for(i=0;i<m;i++){
  38. printf("\n\t LOS NUMEROS COMPLEJOS SON: %s[%i]=%d + %ij",nom,i+1,y[i],t[i]);}
  39. return;}
  40. int suma (int *x,int *d, int m){
  41. int i;
  42. int s=0.0,f=0.0;
  43. for(i=0;i<m;i++){
  44. s+= x[i];}
  45. for(i=0;i<m;i++){
  46. f+= d[i];}
  47. printf("\n\t LA SUMA DE LOS NUMEROS ES %i+ %i j",s,f);
  48. return;
  49. }
  50. int resta (int *x,int *d, int m){
  51. int i;
  52. int s=x[0],f=d[0];
  53. for(i=1;i<m;i++){
  54. s = s-x[i];}
  55. for(i=1;i<m;i++){
  56. f = f-d[i];}
  57. if (f>=0){
  58. printf("\n\t LA RESTA DE LOS NUMEROS ES %i + %i j",s,f);
  59. }
  60. else
  61. {
  62.   printf("\n\t LA RESTA DE LOS NUMEROS ES %i%ij",s,f);
  63. }
  64. return;
  65. }
  66. int multiplicacion(int*x,int*d,int m){
  67. int i,r=1,c=1,v=1;
  68. for(i=0;i<m;i++){
  69. r= r*x[i];} // multiplicacion de reales
  70. for(i=0;i<m;i++){
  71. c= c*d[i];}
  72. //multiplicacion de imaginarios
  73. for(i=0;i<m;i++){
  74. v=v*x[i]*d[i];}
  75. }
3  Programación / Programación C/C++ / Programa matriz en C en: 26 Noviembre 2016, 15:16 pm
Hola, necesito ayuda con este programa
Leer una matriz de dimensión máxima de hasta 3x3 y obtener su determinante por regla de crammer
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines