Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include "pch.h"
  4. #include <vector>
  5. #include <string>
  6.  
  7.  
  8.  
  9. int main() {
  10.  
  11. //Task4
  12. float a, n;
  13. int b;
  14. cin >> a;
  15. whole(a);
  16. cout << a << endl;
  17. whole(&a);
  18. cout << a << endl;
  19.  
  20. //Task7
  21. cout << "Task7 " << endl;
  22. cin >> n;
  23. inverse(n);
  24. cout << n << endl;
  25. inverse(&n);
  26. cout << n << endl;
  27. inverse(b);
  28. cout << b << endl;
  29. inverse(&b);
  30. cout << b << endl;
  31.  
  32.  
  33.  
  34.  
  35. //Task15
  36. cout << "Task15" << endl;
  37. vector<vector<float>> M(3, vector<float>(3));
  38. string str;
  39. for (int i = 0; i < 3; i++) {
  40. for (int j = 0; j < 3; j++) {
  41. cout << "[" << i << "][" << j << "] = ";
  42. cin >> M[i][j];
  43. }
  44. }
  45.  
  46. matrix(M);
  47.  
  48. cout << "Res1:" << endl;
  49. for (int i = 0; i < 3; i++) {
  50. for (int j = 0; j < 3; j++) {
  51. cout << M[i][j] << " ";
  52. }
  53. cout << endl;
  54. }
  55.  
  56. matrix(&M);
  57.  
  58. cout << "Res2:" << endl;
  59. for (int i = 0; i < 3; i++) {
  60. for (int j = 0; j < 3; j++) {
  61. cout << M[i][j] << " ";
  62. }
  63. cout << endl;
  64. }
  65. return 0;
  66. }
  67.  
  68. #include "pch.h"
  69.  
  70. //Task4
  71. void whole(float *a) {
  72. *a = *a / 10;
  73. }
  74.  
  75. void whole(float& a) {
  76. a = a / 10;
  77. }
  78.  
  79.  
  80. //Task #7
  81. void inverse(float* n) {
  82. *n = -*n;
  83. }
  84.  
  85. void inverse(int* b) {
  86. *b = -*b;
  87. }
  88.  
  89. void inverse(float& n) {
  90. n = -n;
  91. }
  92.  
  93. void inverse(int& b) {
  94. b = -b;
  95. }
  96.  
  97. //Task15
  98. void matrix(vector<vector<float>>* M) {
  99. for (vector<float>& line : *M) {
  100. for (float& element : line)
  101. element *= 3;
  102. }
  103. }
  104.  
  105. void matrix(vector<vector<float>>& M) {
  106. for (vector<float>& line : M) {
  107. for (float& element : line)
  108. element *= 3;
  109. }
  110. }
  111.  
  112.  
  113.  
  114. #ifndef PCH_H
  115. #define PCH_H
  116.  
  117. #pragma once
  118. #include <vector>
  119.  
  120. using namespace std;
  121. //Task4
  122. void whole(float* a);
  123. void whole(float& a);
  124.  
  125. //Task7
  126. void inverse(float* n);
  127. void inverse(int* b);
  128. void inverse(float& n);
  129. void inverse(int& b);
  130.  
  131. //Task15
  132. void matrix(vector<vector<float>>* M);
  133. void matrix(vector<vector<float>>& M);
  134.  
  135.  
  136.  
  137. #endif //PCH_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement