【发布时间】:2016-08-15 01:46:13
【问题描述】:
我正在编写一个代码,其中输入一个输入来运行一些测试用例,在每个测试用例中,我们必须通过每个数字迭代数字,我们必须将它除以所采用的初始数字,如果它给出余数 0 那么我们需要增加计数,否则我们不需要增加计数,最后我们将打印计数。
数字12被分成两位数,1和2。当12被除 通过这些数字中的任何一个,计算的余数为 0;就这样 12中可整除的位数是2
编译器消息
浮点异常
代码如下,在c编译器中运行时,程序在接受输入后突然停止。
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int t;
int n[t],b,rem;
int count =0;
scanf("%d",&t);
for(int a0 = 0; a0 < t; a0++){
scanf("%d",&n[a0]);
}
for(int i=0;i<t;i++){
b =n[i];
while (n[i]) {
rem = n[i] % 10;
if(b%rem == 0)
count++;
n[i] = n[i] / 10;
}
printf("%d\n",count);
}
return 0;
}
.
【问题讨论】:
标签: c arrays loops if-statement