
#include<stdlib.h>
#include<string.h>
struct word //定义一个word的结构体,里面的两个成员分别放英语单词和相应的汉语翻译
{
char chinese[20]
char english[20]
}
int point=0 //统计分数的
int count1=0 //测试的次数
void tianjia(struct word str[100],int &count) //函数声明,往词库中添加词组
void shuchu(struct word str[100],int &count) //函数声明,输出词库中所有的词组
void fanyi1(struct word str[100],int &count) //函数声明,输入汉语,对英语翻译的考察
void fanyi2(struct word str[100],int &count)
void chaxun(int point,int count1) //函数声明,输出成绩!
void main()
{
int count=0
struct word str[100] //定义一个结构体数组str
int n
char ch,chioch
while(1)
{
printf("*************背单词系统*********************\n")
printf("*************1,添加词库*********************\n")
printf("*************2,汉译英***********************\n")
printf("*************3,英译汉***********************\n")
printf("*************4,输出所有词库*****************\n")
printf("*************5,成绩查询*********************\n")
printf("*************0,退出*************************\n")
printf("********************************************\n")
printf("请输入你要经行的 *** 作:\n")
scanf("%d",&n)
switch(n)
{
case 1:tianjia(str,count)break //函数调用
case 2:fanyi1(str,count)break //函数调用
case 3:fanyi2(str,count)break //函数调用
case 4:shuchu(str,count)break
case 5:chaxun(point,count1)break //函数调用
case 0:{printf("你确认要退出吗?y/n!!\n")
scanf("%c%c",&ch,&chioch)
if(ch=='y'||ch=='Y') exit(0)
}
default :printf("你输入了错误的 *** 作,无法执行!!!")
exit(0)
}
}
}
void tianjia(struct word str[100],int &count)//往词库中添加词组
{
char ch
do{
printf("录入词库!!!\n")
printf("请输入词库中的英语单词:\n")
scanf("%s",str[count].english)
printf("\n请输入相应的中文意思:\n")
scanf("%s",str[count].chinese)
count++
printf("是否继续录入?y/n!!!\n")
scanf("%s",&ch)
}while(ch=='y')
printf("%d\n\n",count)
}
void shuchu(struct word str[100],int &count) // 输出词库中所有的词组
{
int i=0
printf("输出词库中所有的单词!!!\n")
if(count<=0) {printf("没有任何单词,无法输出!!!\n")return}
else {
for(i=0i<counti++){
printf("英文单词是:%s",str[i].english)
printf("\n相应的中文意思是:%s",str[i].chinese)
printf("\n\n")
}
printf("词库所有单词输入完毕!!!!\n")
}
}
void fanyi1(struct word str[100],int &count)//输入汉语,对英语翻译的考察
{
int i
char ch[20]
char bh[20]
printf("请输入英语单词:\n")
scanf("%s",ch)
printf("请输入翻译后的中文:\n")
scanf("%s",bh)
for(i=0i<counti++)
{
if(strcmp(ch,str[i].english)==0)
{
if(strcmp(bh,str[i].chinese)==0)
{
point++
count1++
printf("恭喜你!!答对了!!!\n")
}
else
{
count1++
printf("很遗憾,答错了!!!正确的翻译是:%s\n",str[i].chinese)
}
}
}
}
void fanyi2(struct word str[100],int &count) //输入英语,对汉语翻译的考察
{
int i
char ch[20]
char bh[20]
printf("请输入中文:\n")
scanf("%s",ch)
printf("请输入翻译后的英文:\n")
scanf("%s",bh)
for(i=0i<counti++)
{
if(strcmp(ch,str[i].chinese)==0)
{
if(strcmp(bh,str[i].english)==0){
point++
count1++
printf("恭喜你!!答对了!!!\n")
}
else
{
count1++
printf("很遗憾,答错了!!!正确的翻译是:%s\n",str[i].english)
}
}
}
}
void chaxun(int point,int count1)
{
printf("本次测试的成绩是:\n")
printf("总共:%d个\n",count1)
printf("正确:%d个\n",point)
// printf("正确率为:%d\%\n",point*100/count1)
}
使用控件 Timer1 Label1,label2,label3Private num As Long '用来变换单词用的
Private word() As Variant '单词存放的数组
Private Sub Form_Load()
word() = Array("hello", "world", "I am ", "Visusl", "basic") '这里有一个五个单词的数组
Label1.AutoSize = True '自动调整大小
Timer1.Interval = 100 '调节速度用的
Label1.Caption = word(0)'初始化单词
'字符挨个渐隐效果
With Label2
.Width = Label1.Width
.Height = Label1.Height
.Caption = ""
.Left = 5000
.Top = Label1.Top
End With
With Label3
.Width = Label1.Width
.Height = Label1.Height
.Caption = ""
.Left = 500
.Top = Label1.Top
End With
End Sub
Private Sub Timer1_Timer()
'向左移动
If Label1.Left >500 Then'这里是规定左边界
Label1.Left = Label1.Left - 100 '每次移动100TWip 可以调节
Else
Label1.Left = 5000 '超过左边界后还原位置
num = num + 1 '同时数组的变量+1 起到更改单词的作用
If num = UBound(word) + 1 Then num = 0 '如果单词全部滚动完毕,则重新开始
Label1.Caption = word(num) '更换单词
'根据不同长度的单词来实现隐藏效果
Label2.Width = Label1.Width
Label3.Width = Label1.Width
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)