Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sortDelim(char str[], const char* delim){
- int i,temp,flag,end,first=0,second=0, strlength, wordscounter, copywordscounter;
- strlength=strilength(str);
- signsreplacer(&str[0], &delim[0]); // replacing any non-numbers chars with ;
- wordscounter=wordsamount(&str[0]); //counting words
- wordscounter--;
- copywordscounter=wordscounter;
- while(wordscounter>0){
- while(copywordscounter>0){
- i=first;
- while(str[first]!=';'&&str[first]>0) first++;
- temp=first;
- second=first+1;
- while(str[second]!=';'&&str[second]>0)second++;
- end=second-1;
- flag=strcmp(&str[0],i,second-1); // checking if the I'll have to swap
- if(flag==1){
- if(end-first>first-i)temp=first+((end-first)-(first-i)); //saving the new ";" position
- else if(end-first<first-i)temp=first+((end-first)-(first-i)); //saving the new ";" position
- }
- swapwords(&str[0],i,second-1); //swapping words
- first=temp;
- first++;
- copywordscounter--;
- }
- first=0;
- wordscounter--;
- copywordscounter=wordscounter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement