编辑代码

#include <iostream>
#include <string.h>
using namespace std;
int main() {
    //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
    char s[128]="1-2,5-6";
    char z[128] = {0};
    int m =0;

    cout << s << endl;
    cout << strlen(s) << endl;

    for (int i=0,j =0; i < 8; )
    {
         cout << "tttttttttttttttt"<< endl;
        cout << s[j] << endl;

         if (s[j] == '-')
        {
            while (s[j+1] != '0'+i) {
                i++;
            }
            i++;
            j=j+2;
        } else if (s[j] == ',') {
            j++;
            cout << ",,,,,,,"<< endl;
        } else if (s[j] == '0'+i) {
            i++;
            j++;
        } else  {
            z[m++]='0'+i;
            z[m++]=',';
            i++;
            // cout << "ssssssssssssssss"<< endl;
            // cout << s[j]<< endl;
            // cout << z[m-1]<< endl;
        }
}
z[strlen(z) - 1] = '\0';
 cout << z << endl;

	cout << "Hello world!    - cpp.jsrun.net." << endl;
	return 0;
}