0

我想做的是找到数字的因素。为此,我创建了两个变量,为了检查它是否是数字的一个因子,我将数字除以检查它是否等于整数。我要你告诉我的是如何检查两个数字的除法是否是整数。

这是我的代码:

int x, y;
        // insert code here...
        NSLog(@"Factors of...");

        scanf("%i", &x);

        NSLog(@"Here are the factors: %i", x/y);

        for (y=0; y <= x; y++) {
            if (x % y = //does not or equals integer){

            }
        }

    }
    return 0;
}
4

1 回答 1

0

这是我的方法:

int x, y;
        //insert code here...
        NSLog(@"Welcome to the factors program. Type in your integer. Up to a 15 digit number!");

        scanf("%i", &x);

        for (y = 1; y <= x; y ++) {

            if (x % y == 0){

            NSLog(@"%i", y); //factors program

            }
            else{

            }
        }


    }
    return 0;
}
于 2012-08-11T21:23:59.657 回答