我想知道下面定义的程序是否可以返回 1 假设:
max/x也不是 in f*x)int canfail(int n, double x) {
double max = 1ULL << n; // 2^n
double f = max / x;
return f * x > max;
}
Run Code Online (Sandbox Code Playgroud)
在我看来,它有时应该返回 1,因为roundToNearest(max / x)通常可以大于max/x。我能够找到相反情况下的数字 where f * x < max,但我没有显示的输入示例,f * x > max我不知道如何找到一个。有人可以帮忙吗?
编辑:如果在 10^(-6) 和 10^6 之间的范围内,我知道 …
main.c:78:25: erreur: assignment from incompatible pointer type [-Werror]
main.c:81:9: erreur: passing argument 2 of ‘matrix_multiply’ from incompatible pointer type [-Werror]
main.c:6:11: note: expected ‘struct matrix_t *’ but argument is of type ‘struct matrix_t *’
Run Code Online (Sandbox Code Playgroud)
第6行是matrix_multiply函数
这是我的代码,从第74行开始
matrix_t *m;
matrix_t *first = matrix_reader_next(reader);
matrix_t *previous = first;
while ( (m = matrix_reader_next(reader))) {
previous->next = m;
previous = m;
}
matrix_t *result = matrix_multiply(first,first->next);
Run Code Online (Sandbox Code Playgroud)
这是我的函数原型和结构
typedef struct {
int **M;
int nLi;
int nCo;
struct matrix_t *next;
} matrix_t;
matrix_t* matrix_multiply(matrix_t* …Run Code Online (Sandbox Code Playgroud)