#include<iostream> using namespace std; int main() { int arry[5]={0,1,3,0,4}; int i=0,j=0,k=0; for(;k<5;++k) { if((i==j)&&(arry[i]!=0)) { ++i; ++j; }
else if(i==j){ j++; } else if(arry[j]==0){ j++; } else if((arry[i] == 0) && (arry[j]!=0)) { int tmp; tmp = arry[j]; arry[j]=arry[i]; arry[i]=tmp; i++; j++; } } for(i=0;i<5;++i) cout<<i; cin.sync(); cin.get(); return 0; } On Sun, Jun 27, 2010 at 1:57 AM, jalaj jaiswal <jalaj.jaiswa...@gmail.com>wrote: > > Given an array of integers, {1,0,2,0,3,0,0,4,5,6,7,0,0,0}, you have to > create a new array which will be like (1,2,3,4,5,6,7,0,0,0,0,0,0,0}, without > using any other temporary array. > > > -- > With Regards, > Jalaj Jaiswal > +919026283397 > B.TECH IT > IIIT ALLAHABAD > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.