| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 394 人关注过本帖
标题:请各位看看这个程序应该怎么改,请将正确的程序代码发上来,谢了!
只看楼主 加入收藏
huaheshang
Rank: 2
来 自:日照
等 级:论坛游民
帖 子:91
专家分:37
注 册:2010-12-7
结帖率:79.31%
收藏
已结贴  问题点数:10 回复次数:2 
请各位看看这个程序应该怎么改,请将正确的程序代码发上来,谢了!

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
int x,y,n=0,flag;
void cover()
{
    printf("-------------------------------------------");
    printf("|             欢迎使用                    |");
    printf("|                                         |");
    printf("|       小学生四则运算测试系统            |");
    printf("|                                         |");
    printf("-------------------------------------------");
     
}
int password()
{
    long password=123456;
    int i=1;
    long pw;
    printf("请输入密码:");
    scanf("%ld",&pw);
    if(password!=pw)
      while(1)
      {
          i++;
          printf("对不起,密码错误!\n 请重新输入密码:");
          scanf("%ld",&pw);
          if(password=pw)
          {
              printf("密码正确。欢迎使用正版软件!\n");
              flag=1;
              break;
          }
          if(i==3)
          {
              printf("打击盗版。你三次输入都不正确,你不能使用这个软件。\n");
              flag=0;
              break;
          }
          }
          else
          {
              printf("密码正确。元婴使用正版软件!");
              flag=1;
          }
          return flag;
     }
     void question()
     {  int rand(void);
         int a,b;
         char ch1;
         
         while(1)
         {
             a=rand()%20+1;
             b=rand()%20+1;
             if(a>=b)
             break;
             }
             printf("\n准备好了吗?");
             printf("单击任意键继续~~~\n");
             scanf("%c",&ch1);
             scanf("%c",&ch1);
             if(a%b==0&&b!=0)
             {
                 printf("%d/%d=",a,b);
                 x=a/b;
             }
             else if(a%3==0)
             {
                 printf("%d*%d=",a,b);
                 x=a*b;
           }
           else if(a%3==1)
           {
               printf("%d+%d=",a,b);
               x=a+b;
           }
           else
           {
               printf("%d-%d=",a,b);
               x=a-b;
           }
     }
     void answers()
     {
         scanf("%d",&y);
         
     }
     int marks()
     {
         if(x==y)
          return 1;
          else
          return 0;
     }
      void result(int r)
      {
          static int score;
          r=marks();
          if(r)
          {
              score+=10;
              printf("恭喜你,答对了!加10分。");
              printf("你的最后得分是%d分。\n",score);
          }
          else
          {
              printf("不好意思,小朋友,你打错了!\n");
              printf("你的最后得分是%d分。\n",score);
          }
    }
   int main(void)
    {
        int m;
        char ans='y';
        cover();
        password();
        if(flag)
        while(ans=='y'||ans=='Y')
        {
            question();
            answers();
            m=marks();
            result(m);
            printf("\n是否继续练习?(Y/N)\n");
            ans =getchar();
    }
    printf("\n谢谢使用,再见!\n");
    return ;
    }
搜索更多相关主题的帖子: 小学生 cover long 
2011-03-08 17:31
qq1023569223
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:湖南科技大学
等 级:贵宾
威 望:26
帖 子:2753
专家分:13404
注 册:2010-12-22
收藏
得分:10 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
int x,y,n=0,flag=0;
void cover()
{
    printf("-------------------------------------------");
    printf("|             欢迎使用                    |");
    printf("|                                         |");
    printf("|       小学生四则运算测试系统            |");
    printf("|                                         |");
    printf("-------------------------------------------");
     
}
int password()
{
    long password=123456;
    int i=0;  //0次
    long pw;
    printf("请输入密码:");
    scanf("%ld",&pw);
    if(password!=pw)
      while(1)
      {
          i++;
          printf("对不起,密码错误!\n 请重新输入密码:");
          scanf("%ld",&pw);
          if(password==pw)  //注意
          {
              printf("密码正确。欢迎使用正版软件!\n");
              flag=1;
              break;
          }
          if(i==3)
          {
              printf("打击盗版。你三次输入都不正确,你不能使用这个软件。\n");
              flag=0;
              break;
          }
       }
          else
          {
              printf("密码正确。元婴使用正版软件!");
              flag=1;
          }
          return flag;
     }
     void question()
     {  
         srand(time(0));
         int a,b;
         char ch1;
         
         while(1)
         {
             a=rand()%20+1;
             b=rand()%20+1;
             if(a>=b)
             break;
          }
             printf("\n准备好了吗?");
             printf("单击任意键继续~~~\n");
             scanf("%c",&ch1);
             scanf("%c",&ch1);
             if(a%b==0&&b!=0)
             {
                 printf("%d/%d=",a,b);
                 x=a/b;
             }
             else if(a%3==0)
             {
                 printf("%d*%d=",a,b);
                 x=a*b;
             }
             else if(a%3==1)
            {
               printf("%d+%d=",a,b);
               x=a+b;
            }
            else
            {
               printf("%d-%d=",a,b);
               x=a-b;
           }
     }
     void answers()
     {
         scanf("%d",&y);
         
     }
     int marks()
     {
         if(x==y)
          return 1;
          else
          return 0;
     }
      void result(int r)
      {
          static int score=0;
          if(r)
          {
              score+=10;
              printf("恭喜你,答对了!加10分。");
              printf("你的最后得分是%d分。\n",score);
          }
          else
          {
              printf("不好意思,小朋友,你打错了!\n");
              printf("你的最后得分是%d分。\n",score);
          }
    }
   int main(void)
    {
        int m;
        char ans='y';
        cover();
        password();
        if(flag)
        while(ans=='y'||ans=='Y')
        {
            question();
            answers();
            m=marks();
            result(m);
            printf("\n是否继续练习?(Y/N)\n");
            ans =getchar();
       }
    printf("\n谢谢使用,再见!\n");
    return 0;
    }

   唯实惟新 至诚致志
2011-03-08 18:49
huaheshang
Rank: 2
来 自:日照
等 级:论坛游民
帖 子:91
专家分:37
注 册:2010-12-7
收藏
得分:0 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
int x,y,n=0,flag=0;
void cover()
{
    printf("                                                  \n");
    printf("                                欢迎使用                      \n");
    printf("                                                  \n");
    printf("                         小学生四则运算测试系统              \n");
    printf("                                                \n");
    printf("                                                  \n");
     
}
int password()
{
    long password=123456;
    int i=0;  //0次
    long pw;
    printf("请输入密码:");
    scanf("%ld",&pw);
    if(password!=pw)
      while(1)
      {
          i++;
          printf("对不起,密码错误!\n 请重新输入密码:");
          scanf("%ld",&pw);
          if(password==pw)  //注意
          {
              printf("密码正确。欢迎使用正版软件!\n");
              flag=1;
              break;
          }
          if(i==3)
          {
              printf("打击盗版。你三次输入都不正确,你不能使用这个软件。\n");
              flag=0;
              break;
          }
       }
          else
          {
              printf("密码正确。欢迎使用正版软件!");
              flag=1;
          }
          return flag;
     }
     void question()
     {  
         srand(time(0));
         int a,b;
         char ch1;
         
         while(1)
         {
             a=rand()%20+1;
             b=rand()%20+1;
             if(a>=b)
             break;
          }
             printf("\n准备好了吗?");
             printf("单击任意键继续~~~\n");
             scanf("%c",&ch1);
             scanf("%c",&ch1);
             if(a%b==0&&b!=0)
             {
                 printf("%d/%d=",a,b);
                 x=a/b;
             }
             else if(a%3==0)
             {
                 printf("%d*%d=",a,b);
                 x=a*b;
             }
             else if(a%3==1)
            {
               printf("%d+%d=",a,b);
               x=a+b;
            }
            else
            {
               printf("%d-%d=",a,b);
               x=a-b;
           }
     }
     void answers()
     {
         scanf("%d",&y);
         
     }
     int marks()
     {
         if(x==y)
          return 1;
          else
          return 0;
     }
      void result(int r)
      {
          static int score=0;
          if(r)
          {
              score+=10;
              printf("恭喜你,答对了!加10分。");
              printf("你的最后得分是%d分。\n",score);
          }
          else
          {
              printf("不好意思,小朋友,你打错了!\n");
              printf("你的最后得分是%d分。\n",score);
          }
    }
   int main(void)
    {
        int m;
        char ans='y',h;
        cover();
        password();
        if(flag)
       {
           
        while(ans=='y'||ans=='Y')
        {   
            question();
            answers();
            m=marks();
            result(m);
            printf("\n是否继续练习?(Y/N)\n");
            printf("您的输入是:");
            getchar();
            scanf("%c",&h);
            printf("%c\n",h);
            ans=h;
        }
        if(ans=='n'||ans=='N')
         {printf("再见!欢迎再次使用!"); }
       }
    }
 
    这是我改进后的程序,大家看看还有哪些方面可以优化一下!
2011-03-09 13:26
快速回复:请各位看看这个程序应该怎么改,请将正确的程序代码发上来,谢了!
数据加载中...
 
   



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

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