C语言编写指法练习程序

C语言编写指法练习程序,第1张

#include<string.h>

#include<alloc.h>

#include<dos.h>

#define SIZE 30

win()

{

clrscr()

gotoxy(20,2)printf("*------------------------------*")

gotoxy(20,3)printf("* Fingering Training System *")

gotoxy(20,4)printf("*Designed By PrOve *")

gotoxy(20,5)printf("*2005-09-06*")

gotoxy(20,6)printf("*------------------------------*")

gotoxy(16,7)printf("...Press any key to entry the System...")

getch()

clrscr()

gotoxy(5,2)printf("Input original text:\n")

gotoxy(5,22)printf("------------------------------------------------------")

gotoxy(5,23)printf(" CorrectRate:%")

gotoxy(33,23)printf("Speed: w/s")

}

main()

{

char o1[150],o2[SIZE],o3[SIZE],o4[SIZE]/*每一行原文,最多150字符*/

char i1[150],i2[SIZE],i3[SIZE],i4[SIZE]/*每一行输入*/

int i

long error = 0,correct = 0

float crate

double speed

double ti

char flag

struct time t1,t2

start:win()

gotoxy(5,4)printf("------------------------------------------------------")

gotoxy(5,3)gets(o1)

gotoxy(5,6)printf("------------------------------------------------------")

gotoxy(5,5)gets(o2)strcat(o1,o2)

gotoxy(5,8)printf("------------------------------------------------------")

gotoxy(5,7)gets(o3)strcat(o1,o3)

gotoxy(5,10)printf("------------------------------------------------------")

gotoxy(5,9)gets(o4)strcat(o1,o4)

gotoxy(5,11)printf("Start Now!\n")

gotoxy(5,13)printf("------------------------------------------------------")

gettime(&t1)/*计时开始*/

gotoxy(5,12)gets(i1)

gotoxy(5,15)printf("------------------------------------------------------")

gotoxy(5,14)gets(i2)strcat(i1,i2)

gotoxy(5,17)printf("------------------------------------------------------")

gotoxy(5,16)gets(i3)strcat(i1,i3)

gotoxy(5,19)printf("------------------------------------------------------")

gotoxy(5,18)gets(i4)strcat(i1,i4)

gettime(&t2)/*计时结束*/

for(i = 0i <strlen(o1)i++)

{

if(o1[i] != i1[i])

error++

else

correct++

}

crate =(float) correct / (float)strlen(i1) * 100

ti = (double)((t2.ti_hour * 3600 + t2.ti_min * 60 + t2.ti_sec ) - (t1.ti_hour * 3600 + t1.ti_min * 60 + t1.ti_sec ))

speed = (double)strlen(i1) / (double)ti

gotoxy(20,23)printf("%f",crate)

gotoxy(40,23)printf("%lf",speed)

gotoxy(5,20)printf("Continue or Not(Y/N) ?")

flag = getch()

if(flag == 'y' || flag == 'Y')

goto start

else

{

clrscr()

gotoxy(26,7)printf("Welcome to use!")

gotoxy(19,8)printf("...Press any key to exit...")

getch()

exit(1)

}

getch()

}

#include <stdio.h>

float a,c

char b

float sf (void) 

{

float g

printf ("a=%f,c=%f,b=%c\n",a,c,b)

switch (b)

{

case '+':g=a+cbreak

case '-':g=a-cbreak

case '*':g=a*cbreak

case '/':g=a/cbreak

default:printf ("符号错误!\n")

}

return g

}

int main ()

{

float g

scanf ("%f%c%f",&a,&b,&c)

g=sf()

printf ("%g%c%g=%g\n",a,b,c,g)

    return 0

}

程序如下: #include<stdio.h>

#include<stdlib.h>

void main()

{

int a[100]

int i=0,j,n

int x,count=0

int re,re1

for(j=0j<=99)

{

n=rand()

if(n>0&&n<100)

{

a[j]=n

j++

}

}

loop: printf("\t\t*********************************\n")

printf("\t\t*菜单 *\n")

printf("\t\t*1: 加 *\n")

printf("\t\t*2: 减 *\n")

printf("\t\t*3: 乘 *\n")

printf("\t\t*4: 除 *\n")

printf("\t\t*5: 退出*\n")

printf("\t\t*********************************\n")

printf("\n请选择菜单:\n")

scanf("%d",&x)

if(1==x)

{

printf("%d + %d = ",a[i],a[i+1])

scanf("%d",&re1)

re=a[i]+a[i+1]

if(re==re1)

{

printf("答对了!\n")

exit(0)

}

else

{

count++

printf("答错了,你还有%d次机会!\n",3-count)

}

}

if(2==x)

{

printf("%d - %d = ",a[i],a[i+1])

scanf("%d",&re1)

re=a[i]-a[i+1]

if(re==re1)

{

printf("答对了!\n")

exit(0)

}

else

{

count++

printf("答错了,你还有%d次机会!\n",3-count)

}

}

if(3==x)

{

printf("%d * %d = ",a[i],a[i+1])

scanf("%d",&re1)

re=a[i]*a[i+1]

if(re==re1)

{

printf("答对了!\n")

exit(0)

}

else

{

count++

printf("答错了,你还有%d次机会!\n",3-count)

}

}

if(4==x)

{

printf("%d / %d = ",a[i],a[i+1])

scanf("%d",&re1)

re=a[i]/a[i+1]

if(re==re1)

{

printf("答对了!\n")

exit(0)

}

else

{

count++

printf("答错了,你还有%d次机会!\n",3-count)

}

}

if(5==x)

exit(0)

if(count<3)

goto loop

if(3==count)

{

printf("你已经没有机会了!\n")

exit(0)

}

}

有疑问提出。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7974890.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-12
下一篇 2023-04-12

发表评论

登录后才能评论

评论列表(0条)

保存