| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 771 人关注过本帖
标题:帮忙写一下c
只看楼主 加入收藏
hanhuoqi2
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2010-6-21
结帖率:100%
收藏
已结贴  问题点数:30 回复次数:4 
帮忙写一下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
无悔爱白修
Rank: 2
等 级:论坛游民
帖 子:28
专家分:27
注 册:2010-3-24
收藏
得分:0 
好难。
2010-06-22 16:08
myhnuhai
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:3
帖 子:425
专家分:1725
注 册:2010-3-17
收藏
得分:30 
呵呵呵

不要让肮脏的记忆,迷失了原本纯洁的心灵!
2010-06-22 16:22
wu644877373
Rank: 2
来 自:湖南
等 级:论坛游民
帖 子:47
专家分:30
注 册:2010-5-11
收藏
得分:0 
谁看的懂?

2010-06-22 17:46
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
快速回复:帮忙写一下c
数据加载中...
 
   



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

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