注册 登录
编程论坛 C++教室

哪位高手来看一下

若是人间 发布于 2008-10-12 17:26, 643 次点击
#include <iostream>
using namespace std;
int count = 0;
int selet (int a){
    while(a>=2){
        if(a%2==0)
        {    count++;
            a=a/2;
        }
        else break;
}
    while(a>=3){
        if(a%3==0)
        {
            count++;
            a=a/3;
        }
        else break;
    }
        return count;

void main(){
    int n;
    cout<<"输入一个整数"<<endl;
    cin>>n;
    selet (n);
    int s;
    s=2*count+2;
    cout<<s;
    }
E:\C++\zhengshu.cpp(22) : error C2601: 'main' : local function definitions are illegal
E:\C++\zhengshu.cpp(31) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

zhengshu.obj - 2 error(s), 0 warning(s)
编译出错;哪位高手帮帮忙呀
7 回复
#2
kakaqq2008-10-12 18:24
#include <iostream>
using namespace std;
int count = 0;
int selet (int a){
    while(a>=2){
        if(a%2==0)
        {    count++;
            a=a/2;
        }
        else break;
}
    while(a>=3){
        if(a%3==0)
        {
            count++;
            a=a/3;
        }
        else break;}   //这
   
        return count;} //这

void main(void)
{
    int n;
    int s;
    cout<<"输入一个整数"<<endl;
    cin>>n;
    selet (n);
    s=2*count+2;
    cout<<s;
    }
注意括号····
#3
无缘今生2008-10-12 18:52
你的程序中的括号都是乱的啊——不配对啊!!!
#4
冰烨2008-10-13 09:09
selet函数最后没有括号,另外main函数最好写成int mian{return 0}的形式
#5
RayBlues2008-10-13 21:07
要注意编程习惯。。。。。。。。。。。。。
#6
choco10242008-10-13 22:22
括号好乱的。
#7
larden2008-10-14 03:16
四楼正解,就return count;后面少了一个括号,四楼把main打错了
#8
冰烨2008-10-15 09:18
[bo][un]choco1024[/un] 在 2008-10-13 22:22 的发言:[/bo]

括号好乱的。

好眼力
1