Guest User

Untitled

a guest
May 25th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <stdio>
  2. #include <conio>
  3. #include <stdlib>
  4. #include <iostream>
  5. #include <windows>
  6. #include <locale>
  7.  
  8. void OutMatr (const double m[][5]);
  9. void Turn180 (double m[][5]);
  10.  
  11. void main (void)
  12. {
  13. setlocale(LC_ALL, "Russian");
  14. SetConsoleOutputCP(1251);
  15. SetConsoleCP(1251);
  16. setlocale(LC_CTYPE, "rus");
  17.  
  18. system("color 0F");
  19.  
  20. double matrx [5][5] = {
  21. {35.4, 50.5, 2.6, 34.7, 67.3},
  22. {40.2, 21.9, 1.8, 23.9, 11.6},
  23. {54.3, 82.6, 16.7, 98.1, 56.6},
  24. {35.4, 79.3, 20.9, 17.8, 72.8},
  25. {23.5, 49.3, 25.6, 35.1, 89.2},
  26. };
  27.  
  28. // Output Matrix on the screen
  29.  
  30. printf("Origin Matrix\n\n"); OutMatr (matrx); printf("\n");
  31.  
  32. // Turn of 180 dgrs Matrix
  33.  
  34. Turn180 (matrx); printf("\n\n");
  35.  
  36. // Output Matrix on the screen
  37.  
  38. printf("New Matrix\n\n"); OutMatr (matrx); printf("\n");
  39.  
  40. //cout<<endl<<endl;
  41. system("pause");
  42. return;
  43. }
  44. //////////////////////////////////
  45. void OutMatr (const double m[][5])
  46. {
  47. int str,pos;
  48. for (str=0; str< 5; str++)
  49. {
  50. for (pos=0; pos< 5; pos++)
  51. {
  52. double x= m[str][pos];
  53. printf("%3.2f\t", (float)x);
  54. }
  55. printf("\n\n");
  56. }
  57. return;
  58. }
  59. //////////////////////////////////
  60. void Turn180 (double m[][5])
  61. {
  62. int str,pos; double swap;
  63.  
  64. // Swap columns
  65.  
  66. int end=4;
  67.  
  68. for (str=0; str< 5; str++)
  69. {
  70. pos= 0;
  71. while (pos!=end)
  72. {
  73. swap= m[str][end]; m[str][end]= m[str][pos]; m[str][pos]= swap;
  74. pos++; end--;
  75. }
  76. end= 4;
  77. }
  78.  
  79. // Swap lines
  80.  
  81. end= 4;
  82.  
  83. for (pos=0; pos< 5; pos++)
  84. {
  85. str= 0;
  86. while (str!=end)
  87. {
  88. swap= m[end][pos]; m[end][pos]= m[str][pos]; m[str][pos]= swap;
  89. str++; end--;
  90. }
  91. end= 4;
  92. }
  93. return;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment