首页 > 用户发贴区 > 编程问题提问区 > 高手帮忙,不胜感激哈
2007
12-05

高手帮忙,不胜感激哈

# include < stdio.h >
# include < string.h >
int fun ( int score [], int m , int below [])
{ int count=0 ,i,j=0,sum=0;
 int avr;
 for(i=0;i<m;i++)
      { sum+= score [i];}
  avr=sum/m;
 while(score [i]<avr)
  { count++;


   below [j]= score [i];
    j++;
  
  return(count);}
}
 
Void main()
{
 int i , n , below [9];
 int score [9] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 } ;
 clrscr () ;
 n = fun ( score , 9 , below ) ;
 printf (“\n below the average scores are :%d “,n);
 for ( i = 0 ; i < n ; i + + )
 printf ( ” % d ” , below [i]);
}


使用Microsoft Visual C++ 6.0在xp系统下运行错误为:


——————–Configuration: Cpp1 – Win32 Debug——————–
Compiling…
Cpp1.cpp
E:\vc\Cpp1.cpp(18) : error C2146: syntax error : missing ‘;’ before identifier ‘main’
E:\vc\Cpp1.cpp(18) : error C2501: ‘Void’ : missing storage-class or type specifiers
E:\vc\Cpp1.cpp(18) : fatal error C1004: unexpected end of file found
Error executing cl.exe.


Cpp1.exe – 3 error(s), 0 warning(s)


偶是菜鸟,请高手指点


高手帮忙,不胜感激哈》有 3 条评论

  1. machongzhen 说:

    还有个问题将

    # include < stdio.h >
    # include < string.h >
    int fun ( int score [], int m , int below [])
    { int count=0 ,i,j=0,sum=0;
     int avr;
     for(i=0;i<m;i++)
          { sum+= score [i];}
      avr=sum/m;
     while(score [i]<avr)
      { count++;

       below [j]= score [i];
        j++;
      
      return(count);}
    }
     
    Void main()
    {
     int i , n , below [9];
     int score [9] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 } ;
     clrscr () ;
     n = fun ( score , 9 , below ) ;
     printf (“\n below the average scores are :%d “,n);
     for ( i = 0 ; i < n ; i + + )
     printf ( ” % d ” , below [i]);
    }

    的红色部分改为void

    错误更多,如下:

    ——————–Configuration: Cpp1 – Win32 Debug——————–
    Compiling…
    Cpp1.cpp
    E:\vc\Cpp1.cpp(20) : error C2018: unknown character ’0xa3′
    E:\vc\Cpp1.cpp(20) : error C2018: unknown character ’0xbb’
    E:\vc\Cpp1.cpp(21) : error C2144: syntax error : missing ‘;’ before type ‘int’
    E:\vc\Cpp1.cpp(22) : error C2065: ‘clrscr’ : undeclared identifier
    E:\vc\Cpp1.cpp(24) : error C2018: unknown character ’0xa3′
    E:\vc\Cpp1.cpp(24) : error C2018: unknown character ’0xbb’
    E:\vc\Cpp1.cpp(25) : error C2143: syntax error : missing ‘;’ before ‘for’
    E:\vc\Cpp1.cpp(25) : error C2059: syntax error : ‘)’
    E:\vc\Cpp1.cpp(26) : error C2018: unknown character ’0xa3′
    E:\vc\Cpp1.cpp(26) : error C2018: unknown character ’0xa9′
    E:\vc\Cpp1.cpp(27) : error C2143: syntax error : missing ‘)’ before ‘}’
    E:\vc\Cpp1.cpp(27) : error C2143: syntax error : missing ‘;’ before ‘)’
    Error executing cl.exe.

    Cpp1.exe – 12 error(s), 0 warning(s)
    为什么会增加如此多错误

    敬请高手指点

    偶不胜感激!!!

  2. wfnh 说:

    例如error C2018: unknown character ’0xa3′

    是你的标点有问题啊,你是不是开了输入法输入的!!是的话,是这样提示的!!!

  3. baly_bao 说:

     

    试一下

    # include < stdio.h >
    # include < string.h >
    int fun ( int score [], int m , int below [],int n)
    { int count=0 ,i,j=0,sum=0;
     int avr;
     for(i=0;i<m;i++)
          { sum+= score [i];}
      avr=sum/m;

       i=0;
     while(score [i]<avr)
      { count++;

       below [j]= score [i];
        j++;
      
      return(count);}
    }
     
    void main()
    {
     int i , n , below [9];
     int score [9] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 } ;
     clrscr () ;
     n = fun ( score ,  below ) ;
     printf (“\n below the average scores are :%d “,n);
     for ( i = 0 ; i < n ; i + + )
     printf ( ” % d ” , below [i]);
    }

留下一个回复