Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

IN MARCH COOK OFF WOULD ANYONE PLEASE PROVIDE ME WHERE I AM WRONG IN FIRST QUESTION

$
0
0

/ MINIMIZING THE STRING CHANDAN KUMAR CSE /

include<stdio.h>

include<string.h>

define s(x) scanf("%d",&x);

define wh(t) while(t--)

int main(void) { int test,len,i,j,pos,pos2,f,k,l,ppp,ds,ts; char str[101],min; s(test) wh(test) { s(len) scanf("%s",str); scanf("\n"); f=0;pos=100; for(i=0;i<len-1;i++) {="" if(f="=1)" break;="" min="str[i];" for(j="i+1;j&lt;len;j++)" {="" if(min="">=str[j]) { min=str[j]; f=1; pos=j; }
} } pos2=100; f=0; for(k=0;k<1;k++) { if(f==1) break; for(l=k+1;l<len;l++) {="" if(str[k]<str[l])="" {="" f="1;pos2=l;" break;="" }="" }="" }="" printf("k="%d\\nl=%d\\npos2=%d\\n",k,l,pos2);" k-="1;" char="" ss[100];="" int="" m,p,g;="" if(l!="len)" for(m="0;m&lt;len;m++)" {="" if(m="=k)" {="" f="1;" }="" if(m+1="=pos2" &&="" f="=1)" {="" ss[m]="str[k];" f="0;" }="" else="" if(f="=1)" ss[m]="str[m+1];" else="" ss[m]="str[m];" }="" else="" {="" for(m="0;m&lt;len-1;m++)" {="" ss[m]="str[m+1];" }="" ss[m]="str[k];" }="" *for(p="0;p&lt;len;p++)" printf("%c\\n",ss[p]);*="" int="" pp="0;" char="" sss[100];="" printf("i="%d\\nmin=%c\\n,pos=%d\\n",i,min,pos);" if(i!="len-1)" {="" i-="1;" for(j="0;j&lt;len;j++)" {="" if(j="=i)" {="" printf("%d\\n",pp);="" sss[pp++]="min;" }="" printf("%c",min);="" else="" if(j="=pos)" j++;="" sss[pp++]="str[j];" printf("%c",str[j]);="" }="" printf("\\n");="" }="" else="" {="" strcpy(sss,str);="" }="" *for(p="0;p&lt;len;p++)" printf("%c\\n",sss[p]);*="" ds="0;ts=0;" int="" x;="" for(x="0;x&lt;len;x++)" {="" if(ss[x]="">sss[x]){ ds=1; break; } if(sss[x]>ss[x]) { ts=1; break; } } if(ts==1) { for(x=0;x<len;x++) printf("%c",ss[x]);="" printf("\\n");="" }="" else="" if(ds="=1)" {="" for(x="0;x&lt;len;x++)" printf("%c",sss[x]);="" printf("\\n");="" }="" else="" if(x="=len)" {="" for(x="0;x&lt;len;x++)" printf("%c",sss[x]);="" printf("\\n");="" }="" *for(i="len-1;i">=1;i++) { for(j=i-1;j>=0;j++) { if(str[i]) } }*/ } return 0; }


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>