| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3723 人关注过本帖
标题:求救--VC++基本程序代码
取消只看楼主 加入收藏
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
还有
我用的一直是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();
}
 
你们自己看看吧   什么不是拿你们的代码
2008-06-26 16:15
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
指导下
时间有限,什么地方可以改进的,麻烦指出下,谢谢……
2008-06-26 16:17
快速回复:求救--VC++基本程序代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041395 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved