vc++乘法练习程序

hou_guannan 2012-02-19 10:21:53
小学生乘法练习程序,随机生成不重复的乘法算式,且被乘数必须小于乘数,由小朋友给出答案,如果不正确,该记录在错题文件中,45个全部练习完后选择继续或退出

问题是如何控制被乘数必须小于乘数,不会是if(a>b)吧!还要用流保存错误记录这个我就不知该从哪下手了,45个后选择继续或退出我也不会,我的技术很烂的,请高手赐教

#include "iostream.h"
#include "stdlib.h"
main()
{
int a,b,i,c;
for(i=0;i<=100;i++)
{
a=1+(int)(10.0*rand()/(RAND_MAX+1.0));
b=1+(int)(10.0*rand()/(RAND_MAX+1.0));

//如何控制被乘数必须小于乘数-----------------------------------
cout<<"how much is"<<a<<" times"<< b <<"?"<<endl;
cin>>c;
if(c==a*b)
{
cout<<"very good"<<endl;
continue;
}
else

//用流保存错误记录这个我就不知该从哪下手了 ---------------------

}
}
...全文
134 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
herokay 大师,这个运行不了呀!
快帮帮我!我的qq260727424,谢谢了
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 herokay 的回复:]
基本框架,没有进行参数检查vs2010

C/C++ code
// times.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;

int _tmain(int argc, ……
[/Quote]


大侠这是哪错了我的是vc6.0,找不到file: 'stdafx.h':
--------------------Configuration: 新建文本文档 (2) - Win32 Debug--------------------
Compiling...
新建文本文档 (2).cpp
c:\users\administrator\desktop\新建文本文档 (2).cpp(4) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
Error executing cl.exe.

新建文本文档 (2).obj - 1 error(s), 0 warning(s)
herokay 2012-02-19
  • 打赏
  • 举报
回复
基本框架,没有进行参数检查vs2010
// times.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,t;
int time=0;
char quit;
ofstream fout;
fout.open("file.dat");
for (int i=0;i<=100;i++)
{
a=rand()%100;
b=rand()%100;
if (a<b)
{
t=a;
a=b;
b=t;
}
cout<<"how much is "<<a<<" times "<< b <<"=?"<<endl;
cin>>c;
if(c==a*b)
{
cout<<"very good"<<endl;
continue;
}
else
{
fout<<a<<"x"<<b<<"="<<c<<endl;
}
time++;
if (time==45)
{
cout<<"You hava finish 45 time.Continue?(Y/N)"<<endl;
cin>>quit;
if (quit=='N')
{
break;
}
else
{
time=0;
}
}
}
fout.close();
return 0;
}

hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
求代码,求说明
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
高手们,我知道这个很弱智,但能不能给点代码说明一下呀
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
能不能给点代码呀。。。。。。,我菜鸟一个。。。。。。
lgstudyvc 2012-02-19
  • 打赏
  • 举报
回复
看标题,我以为啥高深的呢

按照楼上门说的做
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
能不能给点代码呀,我知道原理但不会写代码呀,不知从何入手
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
?????
herokay 2012-02-19
  • 打赏
  • 举报
回复
生成两个随机数a,b;
如果a>b直接用;
否则交换a,b的值;

如果错误,将a,b的值直接插入文件就行了。
  • 打赏
  • 举报
回复
被乘数=min(a,b)
用一个变量记录练习个数,到了45个做处理
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
等待中。。。。。。。。。。。。。
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
在线等了
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 herokay 的回复:]
vc6.0的话 改几行及行了
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;

int main()
[/Quote]

谢谢
hou_guannan 2012-02-19
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 gold_water 的回复:]
加油:老鸟都是从菜鸟过来的。
[/Quote]
谢谢
gold_water 2012-02-19
  • 打赏
  • 举报
回复

加油:老鸟都是从菜鸟过来的。
herokay 2012-02-19
  • 打赏
  • 举报
回复
vc6.0的话 改几行及行了
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;

int main()

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧