为什么它计算的数字如此奇怪?

问题描述 投票:0回答:1
int height = 256;
int width = 256;
for(int i = 0; i<width*height; i++){
    int column = i-(width*(i/width));
    if(column < height/2){
        int number = i + width - 1 - column;
        printf("%d column %d number\n", column, number);
    }
    else i+=column-1;
}

谁能解释一下为什么每256个数字总是相同的,如图所示,而它不应该是?如果可以的话,如何解决这个问题?

enter image description here

c int output
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.