如何在Xcode控制台中检查答案是否为整数
我想做的是找到数字的因子。为了做到这一点,我创建了两个变量,为了检查它是否是数字的一个因子,我将数字除以以检查它是否等于整数。我要求你们告诉我的是如何检查两个数的除法是否为整数 这是我的密码:如何在Xcode控制台中检查答案是否为整数,xcode,Xcode,我想做的是找到数字的因子。为了做到这一点,我创建了两个变量,为了检查它是否是数字的一个因子,我将数字除以以检查它是否等于整数。我要求你们告诉我的是如何检查两个数的除法是否为整数 这是我的密码: int x, y; // insert code here... NSLog(@"Factors of..."); scanf("%i", &x); NSLog(@"Here are the factors: %i", x/y);
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;
}
intx,y;
//在这里插入代码。。。
NSLog(@“因素…”);
scanf(“%i”和“&x”);
NSLog(@“以下是系数:%i”,x/y);
对于(y=0;y,以下是我的方法:
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;
}
intx,y;
//在这里插入代码。。。
NSLog(@“欢迎使用因子程序。输入整数。最多15位数字!”);
scanf(“%i”和“&x”);
对于(y=1;y