Ⅰ vb中如何编一个解类似数学题的程序:x=1,y=2 求的题,就是如和让其代入并计算
建议用VB程序配合VBS脚本
就是VB做好一个程序 点计算按钮的时候 自动生成一个VBS脚本并运行 就OK了
给你一个具体的例子
'botton1的代码:
Open "c:\zhen.vbs" For Output As #1
Print #1, "Public Function f(x,y)"
Print #1, " f=" + Text3.Text
Print #1, "End Function"
Print #1, " x=" + Text1.Text
Print #1, " y=" + Text2.Text
Print #1, "Strings=""结果是:"" & f(x,y)
Print #1, " msgbox Strings,,""完成"""
Close #1
Shell "cmd /c c:\zhen.vbs", vbHide
'其中 text1要输入x的值 text2要输入Y的值 text3输入算式 按下botton1后 结果就弹出来了 写点代码不容易 追加点分吧!
Ⅱ 用 java 编写一个应用程序,对数学题目进行评分
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner ipt = null;
System.out.print("输入题目数:");
ipt = new Scanner(System.in);
int count = ipt.nextInt();
System.out.println("请输入答案:");
ipt = new Scanner(System.in);
String str = ipt.nextLine();//接受输入在同一行的所有答案,保存为包括空格在内的字符串
// System.out.println(str);
String[] strs = str.split(" ");//将输入的字符串以空格为间隔分成一个字符串数组
// System.out.println("长度:"+strs.length);
//将字符串数组转成int数组,数组zqda就是保存的所有正确答案的数组
int[] zqda = new int[count];
for (int i = 0; i < strs.length; i++) {
zqda[i] = Integer.parseInt(strs[i]);
}
System.out.println("请输入自己的答案:");
int[] myda = new int[count];
for (int i = 0; i < myda.length; i++) {
System.out.print(i+1+".");//题号
ipt = new Scanner(System.in);
myda[i] = ipt.nextInt();
}
int yes = 0;//用来记录正确的答案
for (int i = 0; i < myda.length; i++) {
if(zqda[i] == myda[i]) yes++;//如果自己的答案==标准答案,yes+1
}
System.out.println((double)yes/(double)count*100+"%");//百分数输出貌似应该还有其他简单的方法,我一时记不起来,就自己拼了一个
}
}
我也正在学习,刚好用你的例子练了一下,相互学习哈!
Ⅲ C++编写程序实现小学生数学测验功能
参考实例源码如下:
//#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
int i,j,k,l=0,n;
cout<<"小学数学测试"<<endl;
cout<<"请选择想测试的题型:1.+ 2.- 3.* 4./:";
cin>>i;
if(i==1)
{
cout<<"请输入测试题的个数:";
cin>>j;
for(int k1=0;k1<j;k1++)
{
srand((unsigned)time(NULL));
int x1=rand()%100;
int x2=rand()%100;
cout<<x1<<"+"<<x2<<"=:";
cin>>k;
if(k==x1+x2){
cout<<"回答正确!"<<endl;
l++;
}
else
cout<<"回答错误!正确答案为:"<<x1+x2<<endl;
}
}
else if(i==2)
{
cout<<"请输入测试题的个数:";
cin>>j;
for(int k1=0;k1<j;k1++)
{
srand((unsigned)time(NULL));
int x1=rand()%100;
int x2=x1+rand()%50;
cout<<x2<<"-"<<x1<<"=:";
cin>>k;
if(k==x2-x1){
cout<<"回答正确!"<<endl;
l++;
}
else
cout<<"回答错误!正确答案为:"<<x2-x1<<endl;
}
}
else if(i==3)
{
cout<<"请输入测试题的个数:";
cin>>j;
for(int k1=0;k1<j;k1++)
{
srand((unsigned)time(NULL));
int x1=rand()%100;
int x2=rand()%100;
cout<<x1<<"*"<<x2<<"=:";
cin>>k;
if(k==x1*x2){
cout<<"回答正确!"<<endl;
l++;
}
else
cout<<"回答错误!正确答案为:"<<x1*x2<<endl;
}
}
else if(i==4)
{
cout<<"请输入测试题的个数:";
cin>>j;
for(int k1=0;k1<j;k1++)
{
srand((unsigned)time(NULL));
int x1=rand()%100+1;
int x2=x1*(rand()%10);
cout<<x2<<"/"<<x1<<"=:";
cin>>k;
if(k==x2/x1){
cout<<"回答正确!"<<endl;
l++;
}
else
cout<<"回答错误!正确答案为:"<<x2/x1<<endl;
}
}
cout<<"这次测试你作对的题目的个数为"<<l<<"个"<<endl;
cout<<"是否继续测试:0.退出 1.继续:";
cin>>n;
if(n==1){
return main();}
// system("PAUSE");
return 0;
}
Ⅳ 数学题:编写一个程序。。。
// 分别计算1到1000之间所有3的倍数之和和所有7的倍数之和
int main()
{
int sumA = 0; //3的倍数的和
int sumB = 0; //7的倍数的和
for(int i = 1; i <= 1000/3; i++) //3的倍数的个数
{
sumA += i*3;
}
for(int i = 1; i <= 1000/7; i++) //7的倍数的个数
{
sumB += i*7;
}
std::cout << "3的倍数的和: " << sumA << std::endl;
std::cout << "7的倍数的和: " << sumB << std::endl;
return 0;
}
如果要求在一个循环内实现,则
for(int i = 1; i <= 1000/3; i++) //3的倍数的个数
{
sumA += i*3;
if( i<=1000/7)
sumB += i*7;
}
Ⅳ C++编程解决数学问题,求大神!
/*
请输入长方体的长、宽和高(逗号隔开)
:
2,2,2
长方体的体积为:8.000,表面积为:24.000
请输入变量a,b的值(逗号隔开)
:
3,5
交换前
:
a
=
3.000,b
=
5.000
交换后
:
a
=
5.000,b
=
3.000
请输入等比数列的公比和项数(逗号隔开)
:
1.5,12
等比数列的前12项的和为
:
257.493
press
any
key
to
continue
*/
#include
<stdio.h>
#include
<math.h>
int
main()
{
double
a,b,c,q,sum;
double
eps
=
1.0e-6;
int
n;
printf("请输入长方体的长、宽和高(逗号隔开)
:
");
scanf("%lf,%lf,%lf",&a,&b,&c);
printf("长方体的体积为:%.3lf,表面积为:%.3lf\n",a*b*c,2*(a*b
+
b*c
+
c*a));
printf("请输入变量a,b的值(逗号隔开)
:
");
scanf("%lf,%lf",&a,&b);
printf("交换前
:
a
=
%.3lf,b
=
%.3lf\n",a,b);
c
=
a;
a
=
b;
b
=
c;
printf("交换后
:
a
=
%.3lf,b
=
%.3lf\n",a,b);
printf("请输入等比数列的公比和项数(逗号隔开)
:
");
scanf("%lf,%d",&q,&n);
if(fabs(q)
-
1.0
>
eps)
sum
=
1.0
*
(1.0
-
pow(q,n))
/
(1.0
-
q);
else
sum
=
1.0
*
n;
printf("等比数列的前%d项的和为
:
%.3lf\n",n,sum);
return
0;
}
Ⅵ 求大神用C语言设计一个程序帮助小学生练习数学。(具体要求见问题补充)
你自己修改修改:
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <windows.h>
#define IDNO_LENGTH 6
#define CALC_KIND 4
#define CALC_NUM 10
bool checkNo(char idNo[]);
char getSignal();
int getResult(int,int,char);
void takeTest();
//main函数
void main()
{
printf("Please input your four digit ID no(begin with two letters):");
char idNo[IDNO_LENGTH];
do
{
scanf("%s",&idNo);
fflush(stdin);
} while(checkNo(idNo)==false);
printf("1.Start a test\t2.Exitb\n");
int choose;
do
{
printf("选择:");
scanf("%d",&choose);
fflush(stdin);
} while(choose!=1 && choose!=2);
if(choose==1)
takeTest();
else
exit(0);
}
//获取随机运算符
char getSignal()
{
char signal[CALC_KIND]={'+','-','*','/'};
srand((unsigned)time(NULL));
return signal[rand()%4];
}
//获取随机数
int random(double start, double end)
{
return (int)(start+(end-start)*rand()/(RAND_MAX+ 1.0));
}
//运算
int getResult(int num1,int num2,char signal)
{
int res;
switch(signal)
{
case '+':
res=num1+num2;break;
case '-':
res=num1-num2;break;
case '*':
res=num1*num2;break;
case '/':
res=num1/num2;break;
default:
res=0;
printf("运算符不符合规则\n");
}
return res;
}
//列出10道题
void takeTest()
{
clock_t startTime;
startTime=clock();
int index;
int giveRes;
int num1;
int num2;
char signal;
for(index=0;index<CALC_NUM;index++)
{
srand((unsigned)time(NULL));
signal=getSignal();
num1=random(0,100);
num2=random(1,100);
printf("%d%c%d=",num1,signal,num2);
scanf("%d",&giveRes);
fflush(stdin);
if(getResult(num1,num2,signal)==giveRes)
{
printf("correct\n");
}
else
{
printf("wrong\n");
}
}
printf("解10道题用了%lf秒\n",(double)(clock()- startTime)/CLOCKS_PER_SEC);
}
//检测idNo是否合规则,合规则返回true
bool checkNo(char idNo[])
{
int index;
bool flag;
flag=true;
for(index=0;index<IDNO_LENGTH;index++)
{
if(index<2)
{
if(!isalpha(idNo[index]))
{
flag=false;
printf("ID no 不符合规则,重新输入:");
break;
}
}
else
{
if(!isdigit(idNo[index]))
{
flag=false;
printf("ID no 不符合规则,重新输入:");
break;
}
}
}
return flag;
}
Ⅶ 作一个可供小学生数学运算的程序:10以内的加减乘除,能根据输入的题数计算机自动出题,并判断是否正确
Qbasic:
Randomize Timer
INPUT "N="; N
For i = 1 To N
k = Int(Rnd * 4)
Select Case k
Case 0:
a = Int(Rnd * 11)
b = Int(Rnd * 11)
e$ = "+"
c = a + b
Case 1:
c = Int(Rnd * 11)
b = Int(Rnd * 11)
e$ = "-"
a = b + c
Case 2:
a = Int(Rnd * 10)
b = Int(Rnd * 10)
e$ = "*"
c = a * b
Case 3:
c = Int(Rnd * 10)
b = Int(Rnd * 9) + 1
e$ = "/"
a = b * c
End Select
Print a; e$; b; "=";
INPUT d
If c = d Then
Print "right!"
Else
Print "Wrong!"
End If
Next i
Ⅷ 如何编写一个C语言程序,让计算机自动出四则运算计算题,要求自动出0-10之间的四则运算题,并批改结果
少年,写好了,给你参考一下。还可以更复杂。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 10
int Test()
{
int num = 0;
int answer = 0;
int result = 0;
int m = 0;
int n = 0;
char op = 0;
int count = N;
while ( count-- )
{
m = rand() % 10;
n = rand() % 10;
op = rand() % 4;
switch ( op )
{
case 0:
op = '+';
answer = m+n;
break;
case 1:
op = '-';
answer = m-n;
break;
case 2:
op = '*';
answer = m*n;
break;
case 3:
n++;
op = '/';
answer = m/n;
break;
default:
break;
}
printf("\n题目:");
printf("%d%c%d=?\n", m, op, n);
printf("请输入答案:");
scanf("%d", &result);
if ( answer == result )
num++;
}
return num;
}
int main()
{
srand( time(NULL) );
printf("开始做题:\n");
printf("答题结束,你总共答对%d道题目。\n", Test());
return 0;
}
Ⅸ C语言,设计一个程序帮助小学生练习数学。
1L的哥们竟然没有分数也没有读写文件记录,我在他的基础上加了这个功能,采纳谁都可以哦~
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <windows.h>
#define IDNO_LENGTH 6
#define CALC_KIND 4
#define CALC_NUM 10
bool checkNo(char idNo[]);
char getSignal();
int getResult(int,int,char);
void takeTest();
//main函数
void main()
{
printf("Please input your four digit ID no(begin with two letters):");
char idNo[IDNO_LENGTH];
do
{
scanf("%s",&idNo);
fflush(stdin);
} while(checkNo(idNo)==false);
printf("1.Start a test\t2.Check score\t3.Exitb\n");
int choose;
do
{
printf("选择:");
scanf("%d",&choose);
fflush(stdin);
} while(choose!=1 && choose!=2&& choose!=3);
if(choose==1)
{
takeTest();
}else if(choose==2)
{
FILE *fp;
char ch;
if((fp=fopen("score.txt","rt+"))==NULL)
{
printf("\n你还没做过题目测试");
getch();
exit(1);
}
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}
else
{
exit(0);
}
}
//获取随机运算符
char getSignal()
{
char signal[CALC_KIND]={'+','-','*','/'};
srand((unsigned)time(NULL));
return signal[rand()%4];
}
//获取随机数
int random(double start, double end)
{
return (int)(start+(end-start)*rand()/(RAND_MAX+ 1.0));
}
//运算
int getResult(int num1,int num2,char signal)
{
int res;
switch(signal)
{
case '+':
res=num1+num2;break;
case '-':
res=num1-num2;break;
case '*':
res=num1*num2;break;
case '/':
res=num1/num2;break;
default:
res=0;
printf("运算符不符合规则\n");
}
return res;
}
//列出10道题
void takeTest()
{
printf("开始答题,每道题10分,总共100分\n");
clock_t startTime;
startTime=clock();
int index;
int giveRes;
int num1;
int num2;
int score=0;
char signal;
for(index=0;index<CALC_NUM;index++)
{
srand((unsigned)time(NULL));
signal=getSignal();
num1=random(0,100);
num2=random(1,100);
printf("%d%c%d=",num1,signal,num2);
scanf("%d",&giveRes);
fflush(stdin);
if(getResult(num1,num2,signal)==giveRes)
{
printf("correct\n");
score+=10;
}
else
{
printf("wrong\n");
}
}
FILE *fp=fopen("score.txt","w");
fprintf(fp,"分数为%d",score);
fclose(fp);
printf("解10道题用了%lf秒\n",(double)(clock()- startTime)/CLOCKS_PER_SEC);
}
//检测idNo是否合规则,合规则返回true
bool checkNo(char idNo[])
{
int index;
bool flag;
flag=true;
for(index=0;index<IDNO_LENGTH;index++)
{
if(index<2)
{
if(!isalpha(idNo[index]))
{
flag=false;
printf("ID no 不符合规则,重新输入:");
break;
}
}
else
{
if(!isdigit(idNo[index]))
{
flag=false;
printf("ID no 不符合规则,重新输入:");
break;
}
}
}
return flag;
}
Ⅹ 一道数学题编写程序
用JAVA写的
public static void main(String[] args) {
int x,y,z;
int times = 0;
for(x = 1;x <= 19;x++){
for(y = 1;y<=33;y++){
z = 100-x-y;
if((5*x+3*y+z/3)==100){
times++;
System.out.println("第 "+times+" 组解 :公鸡 :"+x+"母鸡:"+y+"小鸡:"+z);
}
}
}
}
程序运行结果:
第 1 组解 :公鸡 :3母鸡:20小鸡:77
第 2 组解 :公鸡 :4母鸡:18小鸡:78
第 3 组解 :公鸡 :7母鸡:13小鸡:80
第 4 组解 :公鸡 :8母鸡:11小鸡:81
第 5 组解 :公鸡 :11母鸡:6小鸡:83
第 6 组解 :公鸡 :12母鸡:4小鸡:84