Created
December 4, 2019 13:26
-
-
Save mk6619/2d837e53d3c5421c94e7a52d07640f24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| void printArrayReverse(int arr[], int start, int end) { | |
| for(int i = end ; i >= start; i--) { | |
| cout<<arr[i]<<" "; | |
| } | |
| } | |
| int main() { | |
| //code | |
| int testCases; | |
| cin>>testCases; | |
| for(int i = 0 ; i < testCases; i++) { | |
| int n,k; | |
| cin>>n; | |
| cin>>k; | |
| int arr[n]; | |
| for(int j =0 ; j < n ; j++) { | |
| cin>>arr[j]; | |
| } | |
| int p = k-1, q = 0; | |
| while(p < n ){ | |
| printArrayReverse(arr, q, p); | |
| q+=k; | |
| p+=k; | |
| } | |
| printArrayReverse(arr,q, n-1); | |
| cout<<endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment