Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct pt
- {
- int x, y;
- pt()
- {
- }
- pt(int x, int y): x(x), y(y)
- {
- }
- };
- template<typename X>
- void masFirst(X *mas, int a, int b)
- {
- for (int i = 0; i<a; i++)
- {
- for (int j = 0; j<b; j++)
- {
- cin >> mas[i][j];
- }
- }
- }
- template<typename X>
- void masSecond(X *mas, int a, int b)
- {
- for (int i = 0; i < a; i++)
- {
- for (int j = 0; j < b; j++)
- {
- cout << mas[i][j]<<"\t";
- }
- cout << endl;
- }
- }
- template <typename X>
- void masAns(X *mas, int a, int b)
- {
- for (int i = 0; i< a; i++)
- {
- if (i % 2 == 0)
- {
- for (int j = 0; j < b; j++)
- {
- cout << mas[i][j]<<"\t";
- }
- }
- else
- {
- for (int j = 0; j < b; j++)
- {
- cout << mas[i][b - j - 1]<<"\t";
- }
- }
- }
- }
- int main()
- {
- int a, b;
- cout << "enter the number of rows and columns" << endl;
- cin >> a >> b;
- pt **mas = new pt*[a];
- for (int count = 0; count < a; count++)
- mas[count] = new pt[b];
- masFirst(mas, a, b);
- masSecond(mas, a, b);
- masAns(mas, a, b);
- for (int count = 0; count < a; count++)
- delete[] mas[count];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement