个人作业一

一、作业信息

博客班级 https://edu.cnblogs.com/campus/ahgc/AHPU-se-JSJ18
作业要求 https://edu.cnblogs.com/campus/ahgc/AHPU-se-JSJ18/homework/11377
作业目标 编写一个可以自动生成支持整数和真分数的四则运算题目的程序
学号 3180701323

二、题目要求
写一个能自动生成小学四则运算题目的程序,然后在此基础上扩展:

1)除了整数以外,还要支持真分数的四则运算,例如:1/6+1/8=7/24

2)程序要求能处理用户的输入,判断对错,累积分数

3)程序支持可以由用户自行选择加、减、乘、除运算

4)使用-n参数控制生成题目的个数,例如Myapp.exe -n 10,将生成10个题目

三:代码提交与运行截图
1:源代码
主函数:

#include<stdio.h>
#include<math.h>
#include<time.h> 
#include<stdlib.h>
#include<windows.h>
int score=0;
void main()
{
 int choise;
 int con=0;
 printf("\n\t\t\t四则运算题目生成\n\n");
 while(1)
 {
  printf("请选择:\n");
  printf("\t\t\t  1.加法运算\\n");
  printf("\t\t\t  2.减法运算\\n");
  printf("\t\t\t  3.乘法运算\\n");
  printf("\t\t\t  4.除法运算\\n");
  if(con==0)
   scanf("%d",&choise);
  switch(choise)
  {
  case 1:
   jia();
   break;
  case 2:
   jian();
   break;
  case 3:
   cheng();
   break;
  case 4:
   chu();
   break;
  }
  printf("\n\t\t\t1.继续运算\n");
  printf("\n\t\t\t2.重新选择\n");
  printf("\n\t\t\t3.退出运算\n");
  scanf("%d",&con);
  if(con==1)
   con=1;
  else if(con==2)
   con=0;
  else if(con==3)
   break;
  else
   printf("抱歉!,你输入的指令有误!请重新输入!\n");
 }
 printf("您的得分是 %d 分\n",score);
}

加法:

void jia()//加法运算
{
 int a,b,c;
 srand((int)time(0));
 a=rand()%100;
 b=rand()%100;
 printf("请回答:\n\t\t %d + %d = ",a,b);
 scanf("%d",&c);
 if(a+b==c)
 {
  printf("回答正确!\n");
  score++;
 }
 else
 {
  printf("回答错误,正确答案是 %d \n",a+b);
 }
}

减法:

void jian()//减法运算
{
 int a,b,c;
 srand((int)time(0));
 a=rand()%100;
 b=rand()%100;
 printf("请回答:\n\t\t %d - %d = ",a,b);
 scanf("%d",&c);
 if(a-b==c)
 {
  printf("回答正确!\n");
  score++;
 }
 else
 {
  printf("回答错误,正确答案是 %d \n",a-b);
 }
}

乘法:

void cheng()//乘法运算
{
 int a,b,c;
 srand((int)time(0));
 a=rand()%100;
 b=rand()%100;
 printf("请回答:\n\t\t %d * %d = ",a,b);
 scanf("%d",&c);
 if(a*b==c)
 {
  printf("回答正确!\n");
  score++;
 }
 else
 {
  printf("回答错误,正确答案是 %d \n",a*b);
 }
}

除法:

void chu()//除法运算
{
 int a,b,c;
 srand((int)time(0));
 a=rand()%100;
 b=rand()%100;
 printf("请回答:\n\t\t %d / %d = ",a,b);
 scanf("%d",&c);
 if(a/b==c)
 {
  printf("回答正确!\n");
  score++;
 }
 else
 {
  printf("回答错误,正确答案是 %d \n",a/b);
 }
}

运行截图:





四:个人小结
首先,我第一次使用博客园写带代码、截图的作业,对各个功能开始有了逐步的了解;
其次,对于真分数的加减乘除还是没有那么明确,思路还是没有那么清晰。

PSP:

psp2.1 任务内容 计划完成需要的时间(min) 实际完成需要的时间(min)
Planning 计划 15 12
Estimate 估计这个任务需要多少时间,并规划大致工作步骤 8 8
Development 开发 120 130
Analysis 需求分析(包括学习新技术) 12 15
Design Spec 生成设计文档 5 6
Design Review 设计复审 5 5
Coding Standard 代码规范 3 4
Design 具体设计 12 16
Coding 具体编码 35 40
Code Review 代码复审 5 6
Test 测试(自我测试,修改代码,提交修改) 10 15
Reporting 报告 10 12
Test Report 测试报告 6 12
Size Measurement 计算工作量 20 25
Postmortem & Process Improvement Plan 事后总结,并提出过程改进计划 5 5
posted @ 2020-11-07 21:25  计算机183何君豪  阅读(90)  评论(0编辑  收藏  举报