Skip to content

Instantly share code, notes, and snippets.

@krishnakumarcn
Created August 6, 2018 18:02
Show Gist options
  • Save krishnakumarcn/1d40460a9a266cd2dda881f57515295f to your computer and use it in GitHub Desktop.
Save krishnakumarcn/1d40460a9a266cd2dda881f57515295f to your computer and use it in GitHub Desktop.
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
int main()
{
printf("Hello World");
//int arr[] = {14,24,63,264,327,585,1,3,572,896} ;
int arr[]= {1,1,1,1,2,1,1,2,4,4};
for (int i=0; i< 10;i++) {
/* code */
int temp ;
if((i%2 == 0 && arr[i]%2==0)||(i%2==1 && arr[i]%2==1)){
continue;
}
else if(i%2==0){
int j;
for(j=i+1;j<10;j++){
if(arr[j]%2==0){
temp = arr[j];
break;
}
}
while(j>i){
arr[j]=arr[j-1];
j--;
}
arr[i] = temp;
}
else{
int j;
for(j=i+1;j<10;j++){
if(arr[j]%2==1){
temp = arr[j];
break;
}
}
while(j>i){
arr[j]=arr[j-1];
j--;
}
arr[i] = temp;
}
}
for(int i=0;i<10;i++){
printf("%d ",arr[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment