Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio>
- #include <conio>
- #include <stdlib>
- #include <iostream>
- #include <windows>
- #include <locale>
- void OutMatr (const double m[][5]);
- void Turn180 (double m[][5]);
- void main (void)
- {
- setlocale(LC_ALL, "Russian");
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- setlocale(LC_CTYPE, "rus");
- system("color 0F");
- double matrx [5][5] = {
- {35.4, 50.5, 2.6, 34.7, 67.3},
- {40.2, 21.9, 1.8, 23.9, 11.6},
- {54.3, 82.6, 16.7, 98.1, 56.6},
- {35.4, 79.3, 20.9, 17.8, 72.8},
- {23.5, 49.3, 25.6, 35.1, 89.2},
- };
- // Output Matrix on the screen
- printf("Origin Matrix\n\n"); OutMatr (matrx); printf("\n");
- // Turn of 180 dgrs Matrix
- Turn180 (matrx); printf("\n\n");
- // Output Matrix on the screen
- printf("New Matrix\n\n"); OutMatr (matrx); printf("\n");
- //cout<<endl<<endl;
- system("pause");
- return;
- }
- //////////////////////////////////
- void OutMatr (const double m[][5])
- {
- int str,pos;
- for (str=0; str< 5; str++)
- {
- for (pos=0; pos< 5; pos++)
- {
- double x= m[str][pos];
- printf("%3.2f\t", (float)x);
- }
- printf("\n\n");
- }
- return;
- }
- //////////////////////////////////
- void Turn180 (double m[][5])
- {
- int str,pos; double swap;
- // Swap columns
- int end=4;
- for (str=0; str< 5; str++)
- {
- pos= 0;
- while (pos!=end)
- {
- swap= m[str][end]; m[str][end]= m[str][pos]; m[str][pos]= swap;
- pos++; end--;
- }
- end= 4;
- }
- // Swap lines
- end= 4;
- for (pos=0; pos< 5; pos++)
- {
- str= 0;
- while (str!=end)
- {
- swap= m[end][pos]; m[end][pos]= m[str][pos]; m[str][pos]= swap;
- str++; end--;
- }
- end= 4;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment