Advertisement
Tavxela

Untitled

Nov 19th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. /*დაწერეთ პროგრამა, რომელიც რამდენიმე მთელ რიცხვის ჩაწერს შესაბამის ვექტორში.
  2. შემდეგ დაბეჭდავს ამ რიცხვებს, და თითოეულ ამ რიცხვთან ერთად აგრეთვე დაბეჭდავს მის კუბს,
  3. აბსოლუტურ მნიშვნელობას, და ფესვს აბსოლუტური მნიშვნელობიდან.
  4. იზრუნეთ, რომ ბეჭდვის ფორმატი იყოს მაქსიმალურად მოხერხებული.*/
  5.  
  6. #include <iostream>
  7. #include <vector>
  8. #include <math.h>
  9.  
  10. using namespace std;
  11.  
  12. void printVector(vector<int>);
  13. void vecCube(vector<int>);
  14. void vecMax(vector<int>);
  15.  
  16. int main() {
  17. cout << "Enter size of the vector" << endl;
  18. vector<int> vector;
  19. int input, inputVS;
  20. cin >> inputVS;
  21. for (int index = 0; index < inputVS; index++) {
  22. cout << "Enter integer" << endl;
  23. cin >> input;
  24. vector.push_back(input);
  25. }
  26. printVector(vector);
  27. vecCube(vector);
  28. vecMax(vector);
  29. }
  30.  
  31. void printVector(vector<int> vectorX) {
  32. cout << "_______________________________" << endl;
  33. for (int index = 0; index < vectorX.size(); index++) {
  34. cout << "Vector[" << index << "] = " << vectorX[index] << endl;
  35. }
  36. }
  37.  
  38. void vecCube(vector<int> vecCube) {
  39. for (int index = 0; index < vecCube.size(); index++) {
  40. cout << "Vector [" << index << "] in cube = " << pow(vecCube[index],3) << endl;
  41. }
  42. }
  43.  
  44. void vecMax(vector<int> vectorMax) {
  45. double max = vectorMax[0], maxIndex = 0;
  46. cout << "_______________________________" << endl;
  47. for (int index = 0; index < vectorMax.size(); index++) {
  48. if (vectorMax[index] > max) {
  49. max = vectorMax[index];
  50. maxIndex = index;
  51. }
  52. }
  53. cout << "vector [" << maxIndex << "] is maximum = " << max << endl;
  54. cout << "Root from maximum vector is " << sqrt(max);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement