Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main(){
long n; scanf("%ld\n", &n);
long x(1), y(n);
for(long p = 0; p < n; p++){
if(p % 2 == 0){printf("%ld ", x++);}
else{printf("%ld ", y--);}
}
puts("");
return 0;
}
Copy The Code &
Try With Live Editor
Input
2
Output
1 2
Demonstration
Codeforces Solution-C. Little Frog-Solution in C, C++, Java, Python