import java.io.File
import java.io.FileReader
import java.io.IOException
import java.util.ArrayList
public class Scanner {
private ArrayList<String>wordlist=new ArrayList<String>()
public void read(File file){
try{
FileReader reader=new FileReader(file)
BufferedReader buf=new BufferedReader(reader)
String str=""
int temp=buf.read()
while(temp!=-1){
if((temp>='A'&&temp<='Z')||(temp>='a'&&temp<='z')){
str+=String.valueOf((char)temp)
}
else{
wordlist.add(str)
str=""
}
temp=buf.read()
}
}catch(IOException e){
e.printStackTrace()
}
}
public ArrayList<String>getWordList(){
return wordlist
}
public void updateWordList(){
wordlist.clear()
}
}
#include "stdio.h"#include "string.h"
struct Node
{
char Ch[19]
Node *next
int count
Node()
}
void Add_word(Node *l)
int Delete_word(char *chr,Node *l)
int Modify_word(char *chr,Node *l)
void Display_word(Node *l)
Node::Node()
{
}
void main()
{
Node *L
L=new Node
L->next=NULL
int n=1,ch
char N[19]
while(n)
{
printf("\n1.添加单词\n")
printf("2.删除单词\n")
printf("3.修改单词\n")
printf("4.所有单词\n")
printf("5.推出程序\n")
printf("\n输入菜单项:")
scanf("%d",&ch)
if(ch==1)
{
printf("\n输入:")
Add_word(L)
printf("添加成功\n")
}
else if(ch==2)
{
printf("要删除的单词:")
scanf("%s",N)
if(Delete_word(N,L))
{
printf("删除成功\n")
}
else printf("无该单词,删除失败")
}
else if(ch==3)
{
printf("要修改的单词:")
scanf("%s",N)
if(Modify_word(N,L))
{
printf("修改成功\n")
}
else printf("无该单词,修改失败")
}
else if(ch==4)
{
Display_word(L)
}
else if(ch==5)
{
n=0
}
}
}
void Add_word(Node *l)
{
Node *s=new Node
scanf("%s",s->Ch)
s->next=l->next
l->next=s
}
int Delete_word(char *chr,Node *l)
{
while(l->next!=NULL)
{
if(strcmp(chr,l->next->Ch)==0)
{
l->next=l->next->next
return 1
}
else
{
l=l->next
}
}
return 0
}
int Modify_word(char *chr,Node *l)
{
while(l->next!=NULL)
{
if(strcmp(chr,l->next->Ch)==0)
{
printf("改成:")
scanf("%s",l->next->Ch)
return 1
}
else
{
l=l->next
}
}
return 0
}
void Display_word(Node *l)
{
while(l->next!=NULL)
{
static int n=0
n++
if(n==4)
printf("\n\n")
printf("%s ",l->next->Ch)
l=l->next
}
}