当前位置: 代码迷 >> C语言 >> 求救--VC++基本程序代码
  详细解决方案

求救--VC++基本程序代码

热度:392   发布时间:2008-06-26 16:09:05.0
虽然不懂C但是比我们版块太差了,既然要收费,俺晕
----------------解决方案--------------------------------------------------------
打下酱油......
----------------解决方案--------------------------------------------------------
还有
我用的一直是C++啊^
你们写的是C啊
I服了U……
还有更正下:我自己些的代码从这没拿走任何代码……
我只是来看看有什么地方可以借鉴的,可是貌似  还没有什么我现在可以借鉴的
#include <iostream.h>
#include <time.h>
#include <stdlib.h>
double addition();
double subtract();
double multiplication();
double division();
int main()
{
    int n;
    cout<<"******************************"<<endl;
    cout<<"    小学生四则运算练习系统    "<<endl;
    cout<<"******************************"<<endl;
    cout<<"          1--加法练习         "<<endl;
    cout<<"          2--减法练习         "<<endl;
    cout<<"          3--乘法练习         "<<endl;
    cout<<"          4--除法练习         "<<endl;
    cout<<"请选择(0--4):";
    cin>>n;
    if(n==1)
    {
        cout<<"加法练习";
        addition();
    }
    else if(n==2)
    {
        cout<<"减法练习";
        subtract();
    }
    else if(n==3)
    {
        cout<<"乘法练习";
        multiplication();
    }
    else if(n==4)
    {
        cout<<"除法练习";
        division();
    }
    else if(n==0)
    {
        cout<<"退出";
        return 0;
    }
    else
    {
        cout<<"输入错误,请重新选择"<<endl;
        return main();
    }

}
double addition()
{
    int a,b,s,k;
    char m;
    srand(time(NULL));
    a=rand()%100;
    b=rand()%100;
    cout<<a<<"+"<<b<<"="<<endl;
    s=a+b;
    cout<<"请输入结果:";
    cin>>k;
    if(k==s)
        cout<<"正确,你真聪明!";
    else
    {
        cout<<"不正确,再想一想,你还有两次机会。"<<endl;
        cin>>k;
        if(k==s)
            cout<<"正确,继续保持!";
        else
        {
            cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            cin>>k;
            if(k==s)
                cout<<"正确,加油!";
            else
            {
                cout<<"不正确,要加强练习喔!正确答案为:"<<s<<endl;
            }
        }
    }
    cout<<"是否继续练习?(Y/N)";
    cin>>m;
    if(m=='n'||m=='N')
        return main();
    else
        return addition();
}
double subtract()
{
    int a,b,s,k;
    char m;
    srand(time(NULL));
    a=rand()%100;
    b=rand()%100;
    cout<<a<<"-"<<b<<"="<<endl;
    s=a-b;
    cout<<"请输入结果:";
    cin>>k;
    if(k==s)
        cout<<"正确,你真聪明!";
    else
    {
        cout<<"不正确,再想一想,你还有两次机会。"<<endl;
        cin>>k;
        if(k==s)
            cout<<"正确,继续保持!";
        else
        {
            cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            cin>>k;
            if(k==s)
                cout<<"正确,加油!";
            else
            {
                cout<<"不正确,要加强练习喔!正确答案为:"<<s<<endl;
            }
        }
    }
    cout<<"是否继续练习?(Y/N)";
    cin>>m;
    if(m=='n'||m=='N')
        return main();
    else
        return subtract();
}
double multiplication()
{
    int a,b,s,k;
    char m;
    srand(time(NULL));
    a=rand()%100;
    b=rand()%100;
    cout<<a<<"*"<<b<<"="<<endl;
    s=a*b;
    cout<<"请输入结果:";
    cin>>k;
    if(k==s)
        cout<<"正确,你真聪明!";
    else
    {
        cout<<"不正确,再想一想,你还有两次机会。"<<endl;
        cin>>k;
        if(k==s)
            cout<<"正确,继续保持!";
        else
        {
            cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            cin>>k;
            if(k==s)
                cout<<"正确,加油!";
            else
            {
                cout<<"不正确,要加强练习喔!正确答案为:"<<s<<endl;
            }
        }
    }
    cout<<"是否继续练习?(Y/N)";
    cin>>m;
    if(m=='n'||m=='N')
        return main();
    else
        return multiplication();
}
double division()
{
    double a,b,s,k;
    char m;
    srand(time(NULL));
    a=rand()%100;
    b=rand()%100;
    cout<<a<<"/"<<b<<"="<<endl;
    s=a/b;
    cout<<"请输入结果:";
    cin>>k;
    if(k==s)
        cout<<"正确,你真聪明!";
    else
    {
        cout<<"不正确,再想一想,你还有两次机会。"<<endl;
        cin>>k;
        if(k==s)
            cout<<"正确,继续保持!";
        else
        {
            cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            cin>>k;
            if(k==s)
                cout<<"正确,加油!";
            else
            {
                cout<<"不正确,要加强练习喔!正确答案为:"<<int((s+0.005)*100)/100.00<<endl;
            }
        }
    }
    cout<<"是否继续练习?(Y/N)";
    cin>>m;
    if(m=='n'||m=='N')
        return main();
    else
        return division();
}

你们自己看看吧   什么不是拿你们的代码
----------------解决方案--------------------------------------------------------
指导下
时间有限,什么地方可以改进的,麻烦指出下,谢谢……
----------------解决方案--------------------------------------------------------
[bo][un]maxsss126[/un] 在 2008-6-26 16:15 的发言:[/bo]

我用的一直是C++啊^
你们写的是C啊
I服了U……


我怎么没看到有C++的影子.

现在啥年代了,还用#include<iostream.h>

还有你的main( )函数设计的非常糟糕.
----------------解决方案--------------------------------------------------------