[原创]家庭儿童计算机管理系统基础核心程序完整代码

作者在 2007-12-21 18:55:22 发布以下内容

DEV-CPP 4.9.9.2 下编译调试通过

原创 BY 孙锴(卧龙孔明)

文件:break.c: /*跳出程序*/

#include<stdio.h>
#include<dos.h>
#include<string.h>
int main(int argc,char **argv)
{
  int t;
  int i;
  char s[100];
  if(argc>2)
  {
    sscanf(argv[2],"%d",&t);
    sleep(t*60000);
    sprintf(s,"taskkill /im %s /f",argv[1]);
    system(s);
  }
  return 0;
}

文件:break.dev /*跳出程序DEV主体*/

[Project]
FileName=break.dev
Name=break
UnitCount=1
Type=0
Ver=1
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
OverrideOutput=0
OverrideOutputName=
HostApplication=
Folders=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=

[Unit1]
FileName=break.c
CompileCpp=0
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[VersionInfo]
Major=0
Minor=1
Release=1
Build=1
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0

文件:Control 第一行为点数,第二行为密码,可以自行编译设置

100
123456
文件:control.c 游戏控制主程序代码

#include<stdio.h>
#include<string.h>
#include<dos.h>
#define MAX 100
typedef struct
{
        char name[30];
        char path[100];
        char exename[30];
        char taskname[30];
} list;
list gamelist[MAX];
char password[20];
int recordnum;
int points;

char p[70];
int initcontrol()
{
    FILE *input,*output;
    char temp[80];
    int i;
    input=fopen("Control.ini","r");
    utput=fopen("Control.tmp","w");
    while(!feof(input))
    {
      fgets(temp,80,input);
      if(temp[0]!=';') fputs(temp,output);
    }
    fclose(input);
    fclose(output);
    input=fopen("Control.tmp","r");     
    fscanf(input,"%d",&recordnum);
    for(i=0;i<recordnum;i++) fscanf(input,"%s%s%s%s",gamelist[i].name,gamelist[i].path,gamelist[i].exename,gamelist[i].taskname);
    fclose(input);
    input=fopen("Control","r");
    fscanf(input,"%d%s",&points,password);
    fclose(input);
}
int startgame(int time)
{
    int n;
    int i;
    printf("\n请选择游戏:1-%d\n",recordnum);
    for(i=0;i<recordnum;i++) printf("%d.%s\n",i+1,gamelist[i].name);
    choice:
    scanf("%d",&n);
    if(n<=recordnum && n>0)
    {
      sprintf(p," %s %d",gamelist[n-1].taskname,time);
      spawnl(1,"D:\\control\\break.exe",p,NULL);
      chdir(gamelist[n-1].path);
      system(gamelist[n-1].exename);
    }
    else
    {
      printf("序号错误!请重新选择\n");
      goto choice;
    }
}
int main(void)
{
    int i=0;
    int n;
    int time;
    FILE *output;
    initcontrol();
    printf("SK-CHINA 2007-2008\n");
    printf("游戏总控制程序\n");
    printf("Game Control BY S.K\n");
    printf("请选择\n1.使用点数\n2.输入家长控制密码\n");
    scanf("%d",&n);
    if(n==1)
    {
      printf("现有点数:%d\n你游戏的每分钟将耗点数1\n",points);
      printf("请设定游戏时间 [单位:分钟]\n");
      re:
      scanf("%d",&time);
      if(time>points)
      {
        printf("点数不够,请重新输入\n");
        goto re;
      }
      points=points-time;
      utput=fopen("Control","w");
      fprintf(output,"%d\n%s",points,password);
      startgame(time);
    }
    if(n==2)
    {
      printf("\n请输入家长控制密码:");
      while(p[i]=getch())
      {
        if(p[i]==13) break;
        if(p[i]!='\b')
        {
          printf("*");
          i++;
        }
        else
        {
          printf("\b \b");
          i--;
        }
      }
      p[i]='\0';
      if(strcmp(password,p)==0)
      {
        printf("\n密码通过!");
        printf("请设定游戏时间 [单位:分钟]\n");
        scanf("%d",&time);
        startgame(time);
      }
      else
      {
        printf("\n密码错误!按任意键退出");
        getch();
        exit(1);
      }
    }   
}

文件:Control.ini 游戏控制设置

;==================================================================
;==================================================================
;记录方式:注释→ “;”后
;游戏控制总记录
;==================================================================
;记录总数
4
;==================================================================
;详细记录
;记录方式:
;游戏名
;游戏路径
;应用程序名
;进程名
三国群英传II
D:\SANGO2\
Sango2.exe
Sango2.exe
游戏王
D:\vba\
VisualBoyAdvance.exe
VisualBoyAdvance.exe
超级玛莉
D:\control\
mario.exe
ntvdm.exe
吃虫子
E:\Games\休闲类\吃虫子\
runturkeyrun.exe
ZapSpot.exe
;==================================================================

文件:Horse.c 赛马场

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define HORSE_NUM 10
struct
{
      char name[10];
      int c;
} data[HORSE_NUM];
int points;
char password[20];
int n;
int main(void)
{
    FILE *input,*output;
    int i,j,k;
    int x,p;
    srand((unsigned)time(NULL));
    input=fopen("Control","r");
    fscanf(input,"%d%s",&points,password);
    fclose(input);
    input=fopen("horse.ini","r");
    fscanf(input,"%d",&n);
    for(i=0;i<n;i++) fscanf(input,"%s%d",data[i].name,&data[i].c);
    fclose(input);
    printf("SK-CHINA 2007-2008\n赛马场 测试版 0.0.1\n");
    printf("现在你有游戏点数:%d\n",points);
    printf("\n现在马的战绩:\n");
    for(i=0;i<n;i++) printf("赛马编号:%d %s 胜利场数:%d\n",i+1,data[i].name,data[i].c);
    printf("请输入下注的赛马编号:");
    scanf("%d",&x); x--;
    if(x>-1 && x<n)
    {
           printf("请输入希望下注的点数:");
           scanf("%d",&p);
           if(p>0 && p<=points)
           {
                  int r[HORSE_NUM]={0};
                  int max=0;
                  int m=12;
                  for(i=0;i<n;i++) if(data[i].c) m--;
                  printf("\n赛马即将进行\n");
                  getch();
                  for(i=0;i<7;i++)
                  {
                    for(j=0;j<20;j++) putchar('\n');
                    for(j=0;j<n;j++)
                    {
                      if(j==x) r[j]+=rand()%m;
                      else r[j]+=rand()%10;
                      for(k=0;k<r[j];k++) printf("."); printf("%s\n",data[j].name);
                    }
                    sleep(1000);
                  }
                  for(i=0;i<n;i++) if(r[i]>r[max]) max=i;
                  printf("\n胜利马匹:%s 赛跑得分%d\n",data[max].name,r[max]);
                  data[max].c+=1;
                  if(max==x)
                  {
                            printf("恭喜!你投注的点数将*10");
                            points=points+p*9;
                            utput=fopen("Control","w");
                            fprintf(output,"%d\n%s",points,password);
                            fclose(output);
                  }
                  else
                  {
                    points=points-p;
                    utput=fopen("Control","w");
                    fprintf(output,"%d\n%s",points,password);
                    fclose(output);
                  }
           }
           else
           {
               printf("输入点数错误,按任意键退出");
               getch();
           }
    }
    else
    {
           printf("赛马编号错误,按任意键退出");
           getch();
    }
    utput=fopen("horse.ini","w");
    fprintf(output,"%d\n",n);
    for(i=0;i<n;i++) fprintf(output,"%s\n%d\n",data[i].name,data[i].c);
    fclose(output);
    while(1);
    return 0;
}

文件:horse.ini 赛马场设置

4
天马
3
赤兔
0
的卢
1
绝影
1

文件: normal.c 测评样板

#include<stdio.h>
#include<conio.h>
#define PI  3.14
#define MAX 10000000
int test_int;
long test_long;
float test_float;
double test_double;
int my()
{
    /*这里写你的代码*/
}
int main(void)
{
  my();
  freopen("out.txt","w",stdout);
  my();
  getch();
  return 0;
}

文件:study.c 学习控制

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<dir.h>
struct
{
      char word[20];
      char mean[4][20];
} words[200];
int testnum;
char record[200];
int mark=0;
int main(void)
{
    time_t time1,time2;
    int n;
    int x;
    int points;
    char path[100];
    char password[20];
    int i,j,k;
    FILE *input,*output;
    srand((unsigned)time(NULL));
    printf("你可以通过学习英语获取游戏点数,每一分钟的学习将获得一点游戏点");
    printf("\n是否学习?[1.学习 2.终止]");
    scanf("%d",&n);
    if(n==1)
    {
            getcwd(path,100);
            chdir("D:\\Program Files\\New Oriental Soft\\New Oriental Words 4\\");
            time1=time(NULL);
            system("Recite4.exe");
            time2=time(NULL);
            x=(int)(difftime(time2,time1)/60);
            if(x<10) x=-5;
            chdir(path);
            printf("\n现在进行测试\n");
            input=fopen("word.ini","r");
            fscanf(input,"%d",&testnum);
            for(i=0;i<testnum;i++)
              fscanf(input,"%s%s%s%s%s",words[i].word,words[i].mean[0],words[i].mean[1],words[i].mean[2],words[i].mean[3]);
            fclose(input);
            input=fopen("word","r");
            for(i=0;i<testnum;i++)
              fscanf(input,"%d",&record[i]);
            fclose(input);
            j=0;
            for(i=0;i<testnum && j<2;i++)
              if(!record[i])
              {
                char r[4]={0};
                char temp;
                j++;
                char c;
                printf("%s\n",words[i].word);
                for(k=1;k<5;k++)
                {
                  while(r[temp=rand()%4]!=0);
                  r[temp]=1;
                  if(temp==0) c=k;
                  printf("%d.%s ",k,words[i].mean[temp]);
                }
                record[i]=1;
                printf("\n请选择英文对应的汉语:");
                scanf("%d",&temp);
                if(temp==c) mark++;
              }
            if(j==2)
            {
              if(mark==2)
              {
                printf("测试优秀,100分,你将获得点数奖励!");
                x+=5;
              }
              else
              if(mark==0)
              {
                printf("测试不理想,0分");
                x=x/3;
              }
              else
              {
                printf("测试一般,50分");
                x=x-15;
              }
            }
            utput=fopen("word","w");
            for(i=0;i<testnum;i++)
              fprintf(output,"%d ",record[i]);
            input=fopen("control","r");
            fscanf(input,"%d%s",&points,password);
            points=points+x;
            fclose(input);
            utput=fopen("control","w");
            fprintf(output,"%d\n%s",points,password);
            fclose(output);
    }
    while(1);
    return 0;
}

文件 test 测试记录

1 1

文件:test.c 测试主程序

#include<stdio.h>
#include<string.h>
typedef struct
{
        char describe[1000];
        char answer[100];
} DATA;
DATA s[20];
char path[100];
int testnum;
char s_p[20];
char password[20];
int points;
int copy(char *infile,char *outfile)
{
    FILE *input,*output;
    char temp;
    if(strcmp(infile,outfile)!=0 && ((input=fopen(infile,"rb"))!=NULL) && ((output=fopen(outfile,"wb"))!=NULL))
    {
      while(!feof(input))
      {
        fread(&temp,1,1,input);
        fwrite(&temp,1,1,output);
      }
      fclose(input);
      fclose(output);
      return 0;
    }
    else return 1;
}
int inittest()
{
    FILE *input,*output;
    int i;
    char temp[80];
    input=fopen("test.ini","r");
    utput=fopen("test.tmp","w");
    while(!feof(input))
    {
      fgets(temp,80,input);
      if(temp[0]!=';') fputs(temp,output);
    }
    fclose(input);
    fclose(output);
    input=fopen("test.tmp","r");     
    fscanf(input,"%s",path);
    fscanf(input,"%d",&testnum);
    for(i=0;i<testnum;i++) fscanf(input,"%s%s",s[i].describe,s[i].answer);
    fclose(input);
    input=fopen("test","r");
    for(i=0;i<testnum;i++) fscanf(input,"%d",&s_p[i]);
    fclose(input);
}
int main(void)
{
  int n;
  int x,i;
  FILE *input,*output;
  char temp[100];
  inittest();
  printf("程序测试 SK-CHINA 2007-2008\n");
  re:
  printf("目前有%d道测试题\n",testnum);
  printf("你还未通过:\n");
  for(i=0;i<testnum;i++) if(s_p[i]) printf("第%2d题\t",i+1);
  printf("\n请输入希望做的题:");
  scanf("%d",&n);
  if(n<=testnum && n>0)
  {
    n--;
    if(s_p[n])
    {
      printf("\n题目叙述:%s\n\n",s[n].describe);
      printf("\n请进入test文件夹,对test.c文件进行添加修改\n");
      printf("\n如果你已经写完,那么请输入1,本程序将进行测试;否则输入0,本程序将退出并新建一个新的程序文件;或输入2,本程序将直接退出,不建立新的程序文件。\n");
      scanf("%d",&x);
      if(x==1)
      {
           sprintf(temp,"%sout.txt",path);
           input=fopen(temp,"r");
           fgets(temp,100,input);
           fclose(input);
           if(strcmp(temp,s[n].answer)==0)
           {
             input=fopen("control","r");
             fscanf(input,"%d%s",&points,password);
             points=points+200;
             fclose(input);
             utput=fopen("control","w");
             fprintf(output,"%d\n%s",points,password);
             fclose(output);
             s_p[n]=0;
             utput=fopen("test","w");
             for(i=0;i<testnum;i++) fprintf(output,"%d ",s_p[i]);
             fclose(output);
             printf("恭喜你,测试正确 !你的游戏点数已增加200");
             getch();
             return 0;
           }
           else
           {
             printf("测试错误,不要气馁,检查一下重新提交!");
             getch();
             return 0;
           }
      }
      else
        if(x==0)
        {
          sprintf(temp,"%stest.c",path);
          copy("Normal.c",temp);
          return 0;
        }
        else return 0;
    }
    else
    {
      printf("本题你已经通过!请重新选择");
      goto re;
    }
  }
  else
  {
    printf("题号输入错误,请重新输入");
    goto re;
  }
  return 0;
}


文件 test.ini 测试主程序设置

;==================================================================
;==================================================================
;记录方式:注释→ “;”后
;测试文件夹
D:\TEST\
;总测试数
2
;测试记录
;格式:
;原题
;标准输出数据
请计算:已知:Q=1*2*3*4*5*6*7*8*9*10,P=1+2+3+4+5+6+7+8+9+10,M=Q/P,SUM=(Q+P+M)*5+4/2*3,请输出SUM.
18474171
请计算:(90+91+92....+99+100)*52.8+PI+MAX/PI,并输出结果.
3239892.515796
;==================================================================

文件:word 单词记录

0 0 0 0 0 0 0 0

文件:word.ini 单词测试表

8
scissors
剪刀 小刀 铅笔 转笔刀
doll
玩具娃娃 钝的 狗 门
balloon
气球 皮球 呼啦圈 圆珠笔
mango
芒果 大门 文盲 盲人
maker
水彩笔 钢笔 作品 制造人
crayon
蜡笔 水彩笔 疯狂的 油画棒
doughnut
甜面圈 面包 面团 蛋糕
honey
蜂蜜 蜜蜂 你好 糖果

原创作品 | 阅读 3523 次
文章评论,共0条
游客请输入验证码