Advertisement
mercMatvey4

Untitled

Dec 14th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. setlocale(LC_ALL,"");
  9. srand(time(0));
  10. double *G = new double[14];
  11. for (int i=0;i<10;i++)
  12. G[i] = rand()%10;
  13. cout << "Исходный массив : \n";
  14. for (int i=0;i<10;i++)
  15. cout << G[i] << "\t";
  16. for (int i=0;i<10;i++)
  17. {
  18. if (i==0 || (i+1)%2!=0)
  19. {
  20. G[i] /= 10;
  21. }
  22. else G[i] = -G[i];
  23. }
  24. cout << "\nКонечный массив : \n";
  25. for (int i=0;i<10;i++)
  26. cout << G[i] << "\t";
  27. cout << endl;
  28. delete[] G;
  29. /*cout << endl << endl << endl; // proverka delete
  30. for (int i=0;i<10;i++)
  31. cout << G[i] << "\t";*/
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement