Advertisement
tei123

głupia szmata

Apr 28th, 2016
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <time.h>
  5. #include <algorithm>
  6. #include <math.h>
  7.  
  8. using namespace std;
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. // 1
  13. int s,s2;
  14. s = 0;
  15. s2 = 0;
  16. srand(time(NULL));
  17. int *wi;
  18. wi = new int;
  19. wi = new int[10];
  20.  
  21. for (int i=0;i<10;i++){
  22. wi[i] = rand()%10;
  23. s += wi[i];}
  24. cout << endl;
  25.  
  26. for (int i=9;i>=0;i--)
  27. cout << wi[i] << " ";
  28. cout << endl;
  29. // 2
  30.  
  31. int *wi2;
  32. wi2 = new int;
  33. wi2 = new int[10];
  34.  
  35. for (int i=0;i<10;i++){
  36. wi[i] = rand()%10;
  37. s2 += wi[i];}
  38. cout << endl;
  39.  
  40. for (int i=9;i>=0;i--)
  41. cout << wi[i] << " ";
  42. cout << endl;
  43.  
  44. if (*wi == *wi2)
  45. cout << " takie same";
  46. else
  47. cout << "rozne";
  48. cout << endl;
  49.  
  50. //suma
  51. cout << s << endl;
  52. cout << s2 << endl;
  53.  
  54. //sort
  55. sort(wi, wi + 10);
  56. for (int i=0;i<0;i++)
  57. cout << wi[i] << " ";
  58. cout << endl;
  59.  
  60. sort(wi2, wi2 + 10);
  61.  
  62. for (int i=0;i<0;i++)
  63. cout << wi2[i] << " ";
  64. cout << endl;
  65.  
  66. //min
  67.  
  68. int min = wi[0];
  69.  
  70. for(int i=1;i<10;i++)
  71. if(min>wi[i])
  72. min = wi[i];
  73.  
  74. cout << min << endl;
  75.  
  76. // max
  77.  
  78. int max = wi[0];
  79.  
  80. for(int i=1;i<10;i++)
  81. if(max<wi[i])
  82. max = wi[i];
  83.  
  84. cout << max << endl;
  85.  
  86. system("PAUSE");
  87. return EXIT_SUCCESS;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement