标题:帮忙写一下c
取消只看楼主
hanhuoqi2
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-6-21
结帖率:100%
已结贴  问题点数:30 回复次数:1 
帮忙写一下c

Write a program that will help elementary school pupils practice math.

a)      The program will first ask the user for his/her ID number (including two letters & 4 digits), e.g.

Please input your four digit ID no: AB1234


       The program should have input validation.

Then the program prompts three choices:

(1)   Start a test

(2)   Check scores

(3)   Exit

 

b)      Test: the program will give 10 math problems, e.g.:

 

12 *  3 = 36

48 + 32 = 80



56 / 28 = 2

 

Note:

i) Pupils will answer each problem before the next one is given.

 

ii) The problems should include addition, subtraction, multiplication and division. They are randomly generated.

 

iii) Randomly generates numbers for problems. However, must ensure that both the problem and the result are no larger than two digits. The problem and the result should be greater than or equal to zero. The divisor cannot be zero.

 

iv) After ten problems are finished, record the time used by the student to do the ten problems.

 

v) Gives a score to each student. Saves this student’s ID, his/her score and the time used into a file named ‘record.txt’.

 

vi) Print the following information on the screen:

Prob. | Correct Answ.  |  Ur Answ

 

c)      Check scores: Searches the file ‘record.txt’ and lists all the historical scores for this student, e.g.:

 

Your previous records are:

AB1234  80  150 seconds

AB1234  50  182 seconds

AB1234  90  98 seconds
搜索更多相关主题的帖子: including first letters practice problems 
2010-06-22 14:23
hanhuoqi2
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-6-21
得分:0 
#include <stdio.h>
#include"ctype.h"
#include"stdlib.h"
#include"math.h"
#include"string.h"
#include "time.h"
void Added(int a[],int i);
void  subtraction(int a[],int m);
void  division(int a[],int m);
void  multiplication (int a[],int m);
void start(int a[],int s[]);
void scour(int a[],int s[],int scours);
int main()
{      int a[10],s[10];   
     int n,scours;
    time_t ts,te;
   
    /*第一步输入ID并且判断是否正确*/
    char ID[6];
    printf("请输入ID:");
    scanf("%s",ID);
    if(isdigit(ID[5])&&isdigit(ID[4])&&isdigit(ID[3])&&isdigit(ID[2])&&isupper(ID[1])&&isupper(ID[0]))
        printf("输入的ID正确,准许进入!");
    else
        printf("您输入的ID有误,请重新输入!");
    /*第二步 选择所要的操作*/
    printf("请输入所要的操作所代表的数字:\n Start a test:1\n check scours:2\n exit:3\n  ");
    scanf("%d",&n);
    switch(n)
    {case 1:
        printf("start test now ");
        ts=time(NULL);
        start(a, s);
        scour( a, s, scours);
        te=time(NULL);
        printf("共花费时间: %d 秒\n\n",ts-te);   
        break;
     case 2:
        printf("your scours is : %d",scours);
        break;
     case 3:
        printf("Thank you for your attendence. goodbye ");
        break;}
}
/*加法运算*/
void Added(int a[],int m)
{  
 int i;
    int b[2],  d;
d=100;
    printf("下面请做第%d题",m);
    do{
   srand(time(NULL));
    for(i=1;i<=2;i++)
    {b[i]=1+(int)rand()%100;}
        d=b[1]+b[2];
   if(d<100)
     {   printf("\n%d+%d=___",b[1],b[2]);
         a[m]=d;}}
    while (d>=100);
}
/*减法运算*/
void  subtraction(int a[],int m)
{  
 int i;
    int b[2],  d;

    printf("下面请做第%d题",m);
    do{
   srand(time(NULL));
    for(i=1;i<=2;i++)
    {b[i]=1+(int)rand()%100;}
        d=b[1]-b[2];
   if(0<=d)
     {   printf("\n%d-%d=___",b[1],b[2]);
         a[m]=d;}}
    while (d<0);
}
/*乘法运算*/
void  multiplication (int a[],int m)
{  
 int i;
    int b[2],  d;
d=100;
    printf("下面请做第%d题",m);
    do{
   srand(time(NULL));
    for(i=1;i<=2;i++)
    {b[i]=1+(int)rand()%100;}
        d=b[1]*b[2];
   if(d<100)
     {   printf("\n%d*%d=___",b[1],b[2]);
         a[m]=d;}}
    while (d>=100);
}
/*除法运算*/
void  division(int a[],int m)
{  
int i;
    int b[2],  d;
d=100;
    printf("下面请做第%d题",m);
    do{
   srand(time(NULL));
    for(i=1;i<=2;i++)
    {b[i]=1+(int)rand()%100;}
        d=b[1]*b[2];
   if(d<100)
     {   printf("\n%d/%d=___",d,b[2]);
         a[m]=b[1];}}
    while (d>=100);
}
    /*出题*/
void start(int a[],int s[])
{int m;
    int q;
    for(m=1;m<=10;m++)
        {srand(time(NULL));
            q=1+(int)rand()%4;
            switch(q)
            {case 1:
                Added(a,m);
                scanf("%d",s[m]);
                break;
             case 2:
               
            subtraction( a, m);
            scanf("%d",s[m]);
            break;
            case 3:
            multiplication (a, m);
            scanf("%d",s[m]);
            break;
            case 4:
            division( a, m);
            scanf("%d",s[m]);
            break;}}}   
/*打分*/
void scour(int a[],int s[],int scours)
{int p;

    for(p=1;p<=10;p++)
    {if(a[p]=s[p])
        scours=+2;};}   
请大家帮我看看为什么只能出一道题啊
2010-06-22 22:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-310937-1-1.html




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

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