error C2040: ‘n‘ : ‘int [1000]‘ differs in levels of indirection from ‘int ‘

简介: error C2040: ‘n‘ : ‘int [1000]‘ differs in levels of indirection from ‘int ‘

这里我犯了很傻子的错误,导致我一直编译出错;

下面代码一直报错

原因:数组名和变量名不能一样,修改一下就好了。


是不是很意外,小编也觉得很意外,可是事实就是这样子.......


---------------------------------------------------------------------------------------------------------------------------------

#include <stdio.h>
int main (void)
{
    /*
给定N个正整数,请统计奇数和偶数各有多少个?
输入格式:
输入第一行给出一个正整N(≤1000);第2行给出N个非负整数,以空格分隔。
输出格式:
在一行中先后输出奇数的个数、偶数的个数。中间以1个空格分隔。
  */
    int n, j = 0, o = 0, i;
    int n[1000] = {0};
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &n[i]);
    }
    for (i = 0; i < n; i++)
    {
        if (n[i] % 2 == 0)
        {
            o++;
        }
        else
        {
            j++;
        }
    }
    printf("%d %d", j, o);
    return 0;
}


目录
打赏
0
0
0
0
7
分享
相关文章
Tensorflow error(二):x and y must have the same dtype, got tf.float32 != tf.int32
本文讨论了TensorFlow中的一个常见错误,即在计算过程中,变量的数据类型(dtype)不一致导致的错误,并通过使用`tf.cast`函数来解决这个问题。
52 0
类型收窄 error C2397: conversion from ‘const int‘ to ‘char‘ requires a narrowing conversion
类型收窄 error C2397: conversion from ‘const int‘ to ‘char‘ requires a narrowing conversion
262 0
Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“
Error:E0415 no suitable constructor exists to convert from “int“ to “Rational“
203 0
关于 error: invalid types ‘int[int]‘ for array subscript 的解决
关于 error: invalid types ‘int[int]‘ for array subscript 的解决
1601 0
关于 error: invalid types ‘int[int]‘ for array subscript 的解决
编译OpenJDK8-u302出错:error C3861: “INT64_C”: 找不到标识符
编译OpenJDK8-u302出错:error C3861: “INT64_C”: 找不到标识符
143 0
解决办法:error: unknown type name ‘__int64‘
解决办法:error: unknown type name ‘__int64‘
527 0
解决办法:error LNK2005: "void * __cdecl operator new(unsigned int)" 已经在 LIBCMTD.lib(new.obj) 中定义
解决办法:error LNK2005: "void * __cdecl operator new(unsigned int)" 已经在 LIBCMTD.lib(new.obj) 中定义
359 0
解决办法:error LNK2005: &quot;void * __cdecl operator new(unsigned int)&quot; 已经在 LIBCMTD.lib(new.obj) 中定义
解决办法:error LNK2005: &quot;void * __cdecl operator new(unsigned int)&quot; 已经在 LIBCMTD.lib(new.obj) 中定义
235 0
caffe: compile error : undefined reference to `cv::imread(cv::String const&, int)&#39; et al.
when I compile caffe file :.build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'.

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等