How to increment a value with leading zeroes?

后端 未结 7 1464
一整个雨季
一整个雨季 2021-02-05 22:23

What would be the best way to increment a value that contains leading zeroes? For example, I\'d like to increment \"00000001\". However, it should be noted that the number of

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 23:00

    "my code is in c" int a[6]={0,0,0,0,0,0},i=5,k,p; while(a[0]!=10) { do { for(p=0;p<=i;p++) printf("%d",a[p]); printf("\n"); delay(100); a[i]++; }while(a[i]!=10); for(k=0;k<=i;k++) if(a[i-k]==10) { a[i-(k+1)]++; a[i-k]=0; } }

提交回复
热议问题