Selamlar.Yapmam gereken:
Given an array of N elements and an integer K (1 <= K <= N), reverse the elements of the array from index K to index N.
Yazdığım kod:
Given an array of N elements and an integer K (1 <= K <= N), reverse the elements of the array from index K to index N.
Yazdığım kod:
Kod:
int main() {
int n ;
cin >> n ;
int array[n] ;
for (int f = 0 ; f< n ; ++f) {
cin >> array[f] ;
}
int k ;
cin >> k ;
for (int f = k-1 ; f < n ; ++f) {
for (int j = n-1 ; j >= f ; --j ) {
int s = array[f];
array[f] = array[j];
array[j] = s;
}
}
for (int f = 0 ; f < n ; ++f) {
cout << array[f] << " " ;
}
cout << endl ;
}