⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tandh.c

📁 delphi控件的使用
💻 C
字号:
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<time.h>
#include<unistd.h>

#include"TandH.h"

static int t_position = 0;
static int h_position = 0;

int	main()
{
	srand(time(NULL));
	do_it();
}

void do_it()
{
	int i, step;
		print_line();
	for(;;){
		fseek(0,0,SEEK_SET);
		i = rand()%10;
		switch(i){
			case 1 :
			case 2 : 
			case 3 : 
			case 4 : 
			case 5 :  step =  3;
				  break;
			case 6 : 
			case 7 :  step = -6;
			 	  break;
			case 8 : 
			case 9 : 
			case 0 :  step = 1;
				  break;
		}
                t_does(step);                 
		switch(i){       
			case 1 : 
			case 2 :  step = 0; 
				  break;
			case 3 : 
			case 4 :  step = 9;
				  break;
			case 5 :  step = -12;
				  break;
			case 6 : 
			case 7 : 
			case 8 :  step = 1;
				  break;
			case 9 :  
			case 0 :  step = -2;
				  break;
		}	
		h_does(step);

		if (t_position >= 70 && h_position >= 70){
			printf("both win\n");
			break;
		}else if (t_position >= 70){
			printf("T win\n");
			break;
		}else if (h_position >= 70){
			printf("H win\n");
			break;
		}
		fflush(0);
		
		sleep(1);
	}
}

void print_line()
{
	printf(
	"----------"
	"----------"
	"----------"
	"----------"
	"----------"
	"----------"
	"----------\n");
	
}

void t_does(int step)
{
	t_position += step;
	if (t_position < 1)
		t_position = 1;	         
/*	printf("%d",t_position);*/
	printf("%*s",t_position,"T");
}

void h_does(int step)
{
	h_position += step;	         
/*	printf("%d",h_position);*/
	if (h_position < 1)
		h_position = 1;	         
	printf("%*s",h_position,"H");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -