จะสอบศัพท์แย้วต้องรีบท่องศัพท์


พอจะรีบท่องศัพท์ ที่ซึ่งวันก่อนพิมพ์ไว้แย้ว
จึงเขียน code สำหรับสุ่มศัพท์มาท่อง
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main()
{
int j=0,i=0,a,word[256][200],mean[256][200],t[256],tt,b[200],c[200];
FILE *fp;
fp =fopen("/wordlist.txt","r");
if(fp==NULL)printf("aaaa");
tt =time(0);
while(!feof(fp))
{
fscanf(fp,"%s",word[i]);
fscanf(fp,"%s",mean[i]);
c[i]=b[i]=0;
i++;
}
while(t[0]!=’q')
{
a = 1+rand_r(&tt)%10;
j +=a;
if(j>=i)j-=(i+1);
printf("%d,%s\n",a,word[j]);
scanf("%s",t);
printf("%s\n",mean[j]);
if(t[0]==’-')b[j]++;
c[j]++;
}
for(j=0;j<i;j++)
{
printf("%15s %3d %3d\n",word[j],c[j],b[j]);
}

}

จะได้รู้ว่าตัวเองจำคำไหนได้บ้าง ไม่ได้บ้าง
ไฟล์คำศัพท์อยู่ในไฟล์ wordlist.txt ในรูปแบบ
ศัพท์
ความหมาย
*** ขั้นด้วย \n
พอหยุดจะมีการพิมพ์สถิติด้วย
เย้ เย้ เย้

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Connecting to %s