关于跳过循环的问题???
程序代码:
本想输出4a1b5g1e4f,结果却是4a3a2a1a1b5g4g3g2g1g1e4f3f2f1f,先是令k=1,判断后面的是否与它相等,相等k=k+1;如何实现跳过3a2a1a,4g3g2g1g,3f2f1f的循环??? #include <stdio.h> #include <string.h> void main() { char s[256] = "aaaabgggggeffff"; int j, k,i ; for(i=0;i<strlen(s);i++) { k=1; for(j=i+1;j<strlen(s);j++) { if(s[i]==s[j]) k++; } printf("%d",k); printf("%c",s[i]); } }