You are viewing a single comment's thread. Return to all comments →
am getting same output but it's shows wrong answer why ??
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ int temp, mid, l, n, k; scanf("%d",&l); scanf("%d",&n); int a[n]; for(int i=0; i<n; i++){ scanf("%d",&a[i]); } k=(n+1)/2; for(int i=0; i<n-1; i++){ for(int j=i+1; j<n; j++) { if(a[i]>a[j]){ temp=a[i]; a[i]=a[j]; a[j]=temp; } } } int temp1=a[k-1]; a[k-1]=a[n-1]; a[n-1]=temp1; int j=n-2; while(k<=j){ int temp3=a[k]; a[k]=a[j]; a[j]=temp3; k++; j--; } for(int i=0;i<n; i++){ printf("%d",a[i]); printf(" "); } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Zig Zag Sequence
You are viewing a single comment's thread. Return to all comments →
am getting same output but it's shows wrong answer why ??
include
include
include
include
int main() {
}