Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. int main()
  2. {
  3. int vet_1[5], vet_2[5], vet_3[10];
  4. int i, tmp, j, k, p, n1, m1;
  5.  
  6. printf("VETTORE 1\n");
  7.  
  8. //chiedo vettore 1
  9.  
  10. printf("\n");
  11. printf("> ");
  12.  
  13. for(i=0; i<5; i++)
  14. {
  15. scanf("%d", &vet_1[i]);
  16. }
  17.  
  18. for(i=0; i<5; i++)
  19. {
  20. printf("%d ", vet_1[i]);
  21. }
  22.  
  23. //ordino vet_1
  24.  
  25. for(j=0; j<5-1; j++)
  26. {
  27. for(i=0; i<5-1; i++)
  28. {
  29. if(vet_1[i]>vet_1[i+1])
  30. {
  31. tmp=vet_1[i];
  32. vet_1[i]=vet_1[i+1];
  33. vet_1[i+1]=tmp;
  34. }
  35. }
  36. }
  37.  
  38. printf("\n> ");
  39. for(i=0; i<5; i++)
  40. {
  41. printf("%d ", vet_1[i]);
  42. }
  43.  
  44. // vettore 2
  45.  
  46. printf("VETTORE 2\n");
  47.  
  48. //chiedo vettore 2
  49.  
  50. printf("\n");
  51. printf("> ");
  52.  
  53. for(i=0; i<5; i++)
  54. {
  55. scanf("%d", &vet_2[i]);
  56. }
  57.  
  58. for(i=0; i<5; i++)
  59. {
  60. printf("%d ", vet_2[i]);
  61. }
  62.  
  63. //ordino vet_2
  64.  
  65. for(j=0; j<5-1; j++)
  66. {
  67. for(i=0; i<5-1; i++)
  68. {
  69. if(vet_2[i]>vet_2[i+1])
  70. {
  71. tmp=vet_2[i];
  72. vet_2[i]=vet_2[i+1];
  73. vet_2[i+1]=tmp;
  74. }
  75. }
  76. }
  77.  
  78. printf("\n> ");
  79. for(i=0; i<5; i++)
  80. {
  81. printf("%d ", vet_2[i]);
  82. }
  83. return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement