ここに私のコードがあります
main.c
#include <stdio.h>
#include <stdbool.h>
#include "func.h"
int main () {
int counts = 10;
printf("Expected: %lF and rcount %lF,%lF\n",
counts * 30* 0.156, rcount(0,30), rcount(30,0));
return 0;
}
ここに私の簡略化されたfunc.hがあります
#ifndef FUNC_INCLUDED
#define FUNC_INCLUDED
float rcount(int m, int n);
#endif
そして最後に私のfunc.c
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include "func.h"
double rcount(int m, int n) {
double series1 = ((double)m/2)*(10+(double)m*10)/20;
double series2 = ((double)n/2)*(10+(double)n*10)/20;
return (series2 > series1) ? series2-series1 : series1-series2;
}
ここで、実行すると のランダムな値が得られますが、メインからrcount()
削除する#include<stdbool.h>
と正しい値が得られます。
何か案が?