我需要帮助。我不明白为什么它一直得到(运行时错误时间:0内存:3460信号:11)
#include <stdio.h>
void CountEvenNumber(int N, int *e);
main()
{
int e;
int i;
int N;
printf("Insert total data : \n");scanf("%d", N);
for(i=1;i<=N; i++)
{
CountEvenNumber(N, &e);
}
printf("Total = %f", &e);
}
void CountEvenNumber(int data, int *even)
{
*even = 0+2;
}
答案 0 :(得分:1)
此代码将为您提供输入数字下方的偶数 #include
void CountEvenNumber(int N, int *e);
int main()
{
int e = 0; //initialize the e by 1 otherwise there is chase to get a garbage value.
int i;
int N;
printf("Insert total data : \n");
scanf("%d", &N);
for(i=1;i<=N; i++)
{
if((i % 2) == 0) //check whether the number is even
{
CountEvenNumber(N, &e);
}
}
printf("Total = %d", e);
}
void CountEvenNumber(int data, int *even)
{
*even = *even + 1; //increment even by 1
}