我有生成1到10个数字的代码:

for (int i = 0; i <=10; i++)
{
     for (int j = 1; j <=10; j++)
     {
         int respones = i;
         int respones1 = j;

         if (respones1 > respones)
         {
              text.append(String.valueOf(respones1));
         }
     }
}

我得到这个结果:
12345678910
2345678910
345678910
45678910
5678910
678910
78910
8910
910
10

但是,我想要这个结果:
12345678910
23456789101
34567891012
45678910123
56789101234
67891012345
78910123456
89101234567
91012345678
10123456789

如何获取代码,以便将第一个数字移动到字符串的末尾?

最佳答案

试试这个:

for (int i = 0; i < 10; i++) {
    for (int j = i + 1; j <= i + 10; j++) {
        int respones = i;
        int respones1 = j;
        if (respones1 > respones) {
            text.append(String.valueOf(respones1 > 10 ? respones1 % 10 : respones1));
        }
    }
}

10-08 15:33