利用指针实现小学生数学四则运算小软件 2018年12月20日

利用指针实现小学生数学四则运算小软件 2018年12月20日
以下内容仅供娱乐,欢迎随时探讨,请多指教
利用函数指针、指针函数、数组指针以及指针数组完成小学生数学四则运算小软件,具体要求如下:
1)要具有自动批改功能。
2)要具有统计已完成题目数量和正确率功能。
3)要具有错题记录和回放功能。
4)参与运算的数据范围可以由使用者设定
5)参与运算的数据在使用者设定范围后随机生成。

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//一道题的结构体
struct problem {
   
   
	int value1;
	char fuhao;
	int value2;
	double answer;
	double result;
};
//一张试卷的结构体
struct testpaper {
   
   
	int txuhao;
	int num;
	int dataMin;//范围
	int dataMax;
	struct problem** next;
	/*
	<param name="ap">
	题目集合
	一级指针指向aTopic结构体,二级指针指向一级指针
	申请空间时,需要多少个题,就申请多少个aTopic结构体的一级指针
	当然直接申请aTopic结构体*N的空间大小给aTopic结构体的一级指针也可以
	*/
};
double keep2(double a);//求百分比约小数点后两位小数的函数
struct testpaper* makeTestPaper();//出试卷函数
void doExam(struct testpaper* tp);//做题函数
struct testpaper* correct(struct testpaper* tp);//批改试卷函数
void showTestPaper(struct testpaper* tp,int answer);//展示结果函数
//主函数
int main()
{
   
   
	int doAgain=0;
	struct testpaper* tp;
	struct testpaper* worngtp;
	struct testpaper* (*poniter)();//函数指针使用 
	poniter=makeTestPaper;
beforel:
	tp=poniter();//出题
	srand(time(NULL));
	system("cls");
	printf("开始答题:\n"
	       "(除法最多保留两位小数,需要四舍五入)\n"
	       "____________分割线_______________\n");
	doExam(tp);
	worngtp=correct(tp);
	while(worngtp->num != 0) {
   
   
		printf("其中做错的题:\n");
		showTestPaper(worngtp,0);
	before:
		printf("\n你是否重做做错的题目?\
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值