| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3723 人关注过本帖
标题:求救--VC++基本程序代码
取消只看楼主 加入收藏
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
 问题点数:0 回复次数:11 
求救--VC++基本程序代码
本系统应包含下列5个函数:
(1)main函数
执行main函数首先产生如下菜单:
          ***************************************************
                     小学生四则运算练习系统
          ***************************************************
                         1--加法练习
                         2--减法练习
                         3--乘法练习
                         4--除法练习
                         0--退出
         请选择(0--4):

当选择某项菜单后,则调用相应的addition函数(加法)、subtract函数(减法)、multiplication函数(乘法)或division函数(除法)进行相应的练习。练习完毕则返回main函数再次显示菜单,练习者可以继续选择其它练习或选择退出。
(2)addition函数(加法)
产生两个随机数,并显示加法练习的题目,然后提示练习者回答。练习者有三次答题机会,如果第一次即回答正确,则显示“正确,你真聪明!”,否则显示“不正确,再想一想,你还有两次机会。”;如果第二次回答正确,则显示“正确,继续保持!”,否则显示“不正确,不要着急,要把握住最后一次机会喔!”;如果第三次回答正确,则显示“正确,加油!”,否则显示“不正确,要加强练习喔!正确答案为:XXX”(“XXX”为正确答案)。当本题完成后,则显示“是否继续练习?(Y/N)”,按任意键则显示下一道练习题,然后可继续进行练习;如果按“N”或“n”,则退出本次练习,并返回main函数。
    我是个学生,现在在实训,老师叫我们写这个程序,各位高手们帮个忙,小弟我给你们敬礼了。
搜索更多相关主题的帖子: 代码 
2008-06-23 09:01
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
还有偿服务,如果我不说我是学生你们会发:“帮助完成作业和设计,收5-50元,QQ联系:674456991 ”吗?哎……
2008-06-23 09:08
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
谢谢
我想先感谢下,给我帮助的朋友,我在这真诚的说声“谢谢”
然后,我要狠狠的鄙视一组发收费写作业的人,下午我们自己做已经做出加法了,我想后面也会更简单,所以你的收费,可以去死了。
2008-06-23 16:26
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
我回来了
看到你们的话,我知道,首先我不是个好学生,也许我拿到我想要的东西就不在回来了,昨天有个人加我,和我说了一大通的话,害的我拿到了你们发的代码,却不敢用,如果我用了,那就意味着我和你们所说 的一样了,现在我在机房,自己做着…… 现在还是在做加法,昨天就已经做出来了,现在还在做,是自己做的,但还是要谢谢给我帮助的人,其次,我想学好C++,我承认我已经学了将近一年了吧,我几乎什么也没学到,好吧  ,就说我什么也没学到,可我有什么办法,现在在学校没人管,自己就不是自己了,偶尔拿来书看看,很简单嘛,就丢一边了,现在在实训,才知道,自己狗屁都不知道。最后,我是昨天才发现这个个网站的 ,我想说,以前我不知道,现在我知道了这个地方,这有我需要的东西,有我要学习 的东西,我回经常来看,虽然我不是个好学生
2008-06-24 09:48
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
我悄悄的告诉你哦
她的网名叫--紫影雪   貌似还是 个MM
2008-06-24 11:52
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
乐极生悲
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

double addition ();
double subtract ();
double multiplication ();
double division ();

int main ()
{
    char shuzi;
    xuanze:
    {
        cout<<"***************************************************"<<endl;
        cout<<endl;
        cout<<"                 小学四则运算练习系统              "<<endl;
        cout<<endl;
        cout<<"***************************************************"<<endl;
        cout<<endl;
        cout<<"                     1--加法练习                   "<<endl;
        cout<<"                     2--减法练习                   "<<endl;
        cout<<"                     3--乘法练习                   "<<endl;
        cout<<"                     4--除法练习                   "<<endl;
        cout<<endl;
        cout<<"                     0--退出                       "<<endl;
        cout<<"请选择(0--4):                                   "<<endl;
        cin>>shuzi;
        switch (shuzi)
        {
            case '1':
                cout<<"你选择了加法练习"<<endl;
                addition ();
                if('n'||'N')
                    goto xuanze;
                break;
            case '2':
                cout<<"你选择了减法练习"<<endl;
                subtract ();
                if('n'||'N')
                    goto xuanze;
                break;
            case '3':
                cout<<"你选择了乘法练习 "<<endl;
                multiplication ();
                if('n'||'N')
                    goto xuanze;
                break;
            case '4':
                cout<<"你选择了除法练习 "<<endl;
                division ();
                if('n'||'N')
                    goto xuanze;
                break;
            case '0':
                cout<<"按任意键退出"<<endl;
                break;
            default:
            {
                goto xuanze;
            }
        }

    }
    return 0;
}

double addition ()
{
    int n,a,b,s;
    wenti:
    {
        time(NULL);
        srand(time(NULL));
        a=rand()%100;
        b=rand()%100;
        s=a+b;
        cout<<a<<"+"<<b<<"=?"<<endl;
        cin>>n;
        if(n==s)
        {
            cout<<"正确,你真聪明!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"结果不对,你再想想,你还有两次机会!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,继续保持!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,加油!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,要加强练习喔!"<<" "<<"正确答案为:"<<s<< endl;
                cout<<endl;
                goto xunwen;
            }
        }
        xunwen:
        {
            char ch;
            cout<<"是否繼續?是Y/否N"<<endl;
            cin>>ch;
            if (ch=='n' || ch=='N')
            {
                return s;
            }
            else
            {
                if (ch=='y' || ch=='Y')
                {
                    goto wenti;
                }
                else
                {
                    goto xunwen;
                }
            }
        }
    }
}

double subtract ()
{
    int n,a,b,s;
    wenti:
    {
        time(NULL);
        srand(time(NULL));
        a=rand()%100;
        b=rand()%100;
        s=a-b;
        cout<<a<<"-"<<b<<"=?"<<endl;
        cin>>n;
        if(n==s)
        {
            cout<<"正确,你真聪明!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"结果不对,你再想想,你还有两次机会!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,继续保持!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,加油!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,要加强练习喔!"<<" "<<"正确答案为:"<<s<< endl;
                cout<<endl;
                goto xunwen;
            }
        }
        xunwen:
        {
            char ch;
            cout<<"是否繼續?是Y/否N"<<endl;
            cin>>ch;
            if (ch=='n' || ch=='N')
            {
                return s;
            }
            else
            {
                if (ch=='y' || ch=='Y')
                {
                    goto wenti;
                }
                else
                {
                    goto xunwen;
                }
            }
        }
    }
}

double multiplication ()
{
    int n,a,b,s;
    wenti:
    {
        time(NULL);
        srand(time(NULL));
        a=rand()%100;
        b=rand()%100;
        s=a*b;
        cout<<a<<"*"<<b<<"=?"<<endl;
        cin>>n;
        if(n==s)
        {
            cout<<"正确,你真聪明!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"结果不对,你再想想,你还有两次机会!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,继续保持!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,加油!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,要加强练习喔!"<<" "<<"正确答案为:"<<s<< endl;
                cout<<endl;
                goto xunwen;
            }
        }
        xunwen:
        {
            char ch;
            cout<<"是否繼續?是Y/否N"<<endl;
            cin>>ch;
            if (ch=='n' || ch=='N')
            {
                return s;
            }
            else
            {
                if (ch=='y' || ch=='Y')
                {
                    goto wenti;
                }
                else
                {
                    goto xunwen;
                }
            }
        }
    }
}

double division ()
{
    double n,a,b,s;
    wenti:
    {
        time(NULL);
        srand(time(NULL));
        a=rand()%100;
        b=rand()%100;
        s=a/b;
        cout<<a<<"/"<<b<<"=?"<<endl;
        cin>>n;
        if(n==s)
        {
            cout<<"正确,你真聪明!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"结果不对,你再想想,你还有两次机会!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,继续保持!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,不要着急,要把握住最后一次机会喔!"<<endl;
            }
        }
        cin>>n;
        if(n==s)
        {
            cout<<"正确,加油!"<<endl;
            goto xunwen;
        }
        else
        {
            if(n!=s)
            {
                cout<<"不正确,要加强练习喔!"<<" "<<"正确答案为:"<<s<< endl;
                cout<<endl;
                goto xunwen;
            }
        }
        xunwen:
        {
            char ch;
            cout<<"是否繼續?是Y/否N"<<endl;
            cin>>ch;
            if (ch=='n' || ch=='N')
            {
                return s;
            }
            else
            {
                if (ch=='y' || ch=='Y')
                {
                    goto wenti;
                }
                else
                {
                    goto xunwen;
                }
            }
        }
    }
}
   就是这样了
可是
可是
……
老师竟然说不能用……
!·#¥%……
没天理啊  说是可读性太差,我没容易吗,
又要从来,忙了一个下午想来想去还是 goto语句好用啊 ……
哎……  
烦恼了
2008-06-24 16:19
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
C++
我们学的就是C++啊
可是 我们用的却是VC6.0啊
我以为VC就和C++一样
…………
现在在忙碌ing
很烦恼ing
……
整个世界都在转了
2008-06-24 17:11
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
又是悲伤事
刚刚得到的新消息:老师说了连递归语句也不能用……
晕了……
还让人活吗
继续重来吧
2008-06-24 17:58
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
好了 ,麻烦大家指导下
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

double addition ();
double subtract ();
double multiplication ();
double division ();

double main()
{
  cout<<"*************************************"<<endl;
  cout<<"       小学生四则运算练习系统        "<<endl;
  cout<<"*************************************"<<endl;
  cout<<"            1--加法练习              "<<endl;
  cout<<"            2--减法练习              "<<endl;
  cout<<"            3--乘法练习              "<<endl;
  cout<<"            4--除法练习              "<<endl;
  cout<<"            0--退出                  "<<endl;
  cout<<" 请选择 (0--4): "<<endl;
  char x;
  cin>>x;
  if (x=='1')
  {
      cout<<"您选择了加法练习: "<<endl;
      addition ( );
  }
  if (x=='2')
  {
      cout<<"您选择了减法练习:"<<endl;
      subtract ();
  }

  if (x=='3')
  {
      cout<<"您选择了乘法练习: "<<endl;
      multiplication ();
  }
  if (x=='4')
  {
      cout<<"您选择了除法练习:"<<endl;
      division ();
  }
  if (x=='0')
  {
      exit (1);
  }    
  else
  {
      cout<<"请选择 (0--4)"<<endl;
      return main();
  }
}


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

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

    if (z=='n'||z=='N')
    {
        return main ();
    }
    else
        return multiplication ();
}


double division ()
{
    double a,b,c,s;
    cout<<"你选择了除法练习(结果四舍五入,保留两位小数)"<<endl;
    do
    {
        srand (time(NULL));
        a=rand ()%100;
        b=rand ()%100;
    }
    while (b==0);
    cout<<a<<"/"<<b<<"="<<endl;
    s=a/b;
 
    cout<<"请输入计算结果:"<<endl;
    s=int(s*100.0+0.5)/100.00;
    cin>>c;
    if (s==c)
    {
        cout<<"正确,你真聪明!"<<endl;
        cout<<"是否要继续练习? (Y/N)"<<endl;
        char z;
        cin>>z;
        if (z=='n'||z=='N')
        {
            return main ();
        }
        else
            return division ();
    }
    else cout<<"不正确,再想一想,你还有两次机会!"<<endl;
    cin>>c;
    if (s==c)
    {
        cout<<"正确,继续保持!"<<endl;
        cout<<"是否要继续练习? (Y/N)"<<endl;
        char z;
        cin>>z;
        if (z=='n'||z=='N')
        {
            return main ();
        }
        else
            return division ();
    }
    else cout<<"不正确,不要着急,要把握住最后一次机会喔"<<endl;
    cin>>c;
    if (s==c)
    {
        cout<<"正确,加油!"<<endl;
        cout<<"是否要继续练习? (Y/N)"<<endl;
        char z;
        cin>>z;
        if (z=='n'||z=='N')
        {
            return main ();
        }
        else
            return division ();
    }
    else cout<<"不正确,要加强练习喔!正确的答案为:"<<s<<endl;
    cout<<"是否要继续练习? (Y/N)"<<endl;
    char z;
    cin>>z;
    if (z=='n'||z=='N')
    {
        return main ();
    }
    else
        return division ();
}




长是长了点  但水平有限
有地方什么能改进的  有什么要提问的
有什么地方有错的  
请大家多多指导啊
谢谢大家的 支持
努力  努力……
2008-06-25 13:19
maxsss126
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-6-23
收藏
得分:0 
没天理啊!!!!!!
昨天下于电脑被劈了,我关了机的啊!@#$%^&**
回家又要挨骂了……  哎……倒霉了
不过倒霉的不只我一个 ……
你们就没用发现我发的程序不能实现的功能吗
我叫你们帮我改下
结果你们发些牛B程序来
不是纯粹打击我嘛
还好……
我自己改好程序了
小小的嗨下……
谢谢 大家  的支持
2008-06-26 15:13
快速回复:求救--VC++基本程序代码
数据加载中...
 
   



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

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