#include<stdlib.h>
#include<dos.h>
#include<windows.h>
#include<string.h>
#include<time.h>
#define item 1000
#define N 10
void closeWindows()//20秒关机文件命令
{
FILE *fp;
if((fp=fopen("关机.bat","w"))==NULL)
{
printf("The file %s can not be opened.\n","关机.bat");
}
fprintf(fp,"shutdown -s -t 20");
fclose(fp);
if((fp=fopen("关机.bat","r"))==NULL)
{
printf("The file %s can not be opened.\n","关机.bat");
}
}
void dictionary()//学eclipse用的词典工具
{
printf("This program is about Myeclipes's word translate\n");
printf("If you dont need continue,you can input [over]\n");
for(int a=0;a<100;a++)
{
char word[100]={0};
char over[10]={"over"};
printf("please input one word!\n");
scanf("%s",&word);
FILE *dic,*hello;
char num[item][30],temp[1000],chinese[item][30];
int i=0,j,c=0;
dic=fopen("book.txt","r");
hello=fopen("chinese.txt","r");
while(fscanf(dic,"%s",num[i])!=EOF)
{
i++;
}
while(fscanf(hello,"%s",chinese[c])!=EOF)
{
c++;
}
for(j=0;j<i;j++)
{
if(strcmp(word, num[j])==0)
{
// printf("%s\n",num[j]);
printf("Translate:\n");
printf("%s\n",chinese[j]);
}
if(strcmp(word, over)==0)
{
goto loop;
}
}
fclose(dic);
fclose(hello);
}
loop: printf("Thank you use this\n");
}
void guessFourNumber()//文曲星数字游戏
{
printf("-------------规则--------\n");
printf("****A代表位置对了,数字对了\n");
printf("****B代表位置不对,数字对了\n");
printf("****只有十次机会\n");
int arr[4],guess[4],m,n,a=0,s;
srand(time(NULL));
//得到四个不重复的数
while(a<4)
{
s=rand()%10;
for(int i=0;i<a;i++)
if(arr[i]==s)
continue;
arr[a++]=s;
}
printf("猜猜我想的是哪四个数字\n");
//for(int i=0;i<4;i++)//测试
//{
//printf("%d\t",arr[i]);
//}
for(int c=0;c<N;c++)
{
for(int j=0;j<4;j++)
{
scanf("%d",&guess[j]);
}
// 取随机数 0-9 4个
m=0;
n=0;
for(int k=0;k<4;k++) //4次判断得出m,n(m表示数字对了位置对了,n表示数字对了位置没对)
{
if(guess[k]==arr[k])
m++;
for(int i=0;i<4;i++)
{
if(k!=i)
{
if(guess[k]==arr[i])
{
n++;
}
}
}
}
printf("%dA%dB\n",m,n);
if(m==4)
goto loop;
if(c==N-1)
goto wrong;
}
loop :printf("你猜对了!");
wrong : printf("游戏结束!");
}
int fn(int x)//阶乘问题
{
long int a;
if(x==1)
return 1;
else
a=x*fn(x-1);
return a;
}
void factorial()
{
printf("请输入你要求的阶乘:\n");
int a;
scanf("%d",&a);//是几的阶乘就输入几
printf("%d",fn(a));
}
int fnhano(int x)//汉诺塔问题
{
int a;
if(x==1)
return 1;
else
a=fnhano(x-1)+fnhano(x-1)+1;
return a;
}
void hano(int n,char a,char b,char c)
{
if(n==1)
printf("将%d个盘片从%c移动到%c\n",n,a,c);
else{
hano(n-1,a,c,b);
printf("将第%d个盘片从%c移动到%c\n",n,a,c);
hano(n-1,b,a,c);
}
}
void hanota()
{
int n;
printf("输入将要移动多少个盘子n:");
scanf("%d",&n);
printf("移动次数%d\n",fnhano(n));
printf("递归结果:\n");
hano(n,'a','b','c');
}
int main()
{
int select;
printf("功能:\n");
printf("1.关机\n");
printf("2.词典\n");
printf("3.文曲星数字游戏\n");
printf("4.阶乘问题\n");
printf("5.汉诺塔问题\n");
printf("输入你要的功能编号:\n");
scanf("%d",&select);
if(select==1)
closeWindows();
if(select==2)
dictionary();
if(select==3)
guessFourNumber();
if(select==4)
factorial();
if(select==5)
hanota();
}
文件是TXT文件,不能上传可以自己做
当时英语不好,学Myeclipse的时候全英文看不懂自己就想做个C语言程序词典
虽然不是非常好,但是可以一用,供参考
上面所涉及到的文件内容
chinese.txt
编辑
重构
导航
搜查
打包
使回复原状
更新
系统默认值
变换
行
定界符
转换
重新启动
输入
输出
性能;道具,内容(property的复数形式)
取消
合格的
粘贴
选择
扩大
元素
封闭
以前的
增加的,增值的
书签;标记
模式
插入
工具提示;提示信息
内容
帮助
完成
修复
方法;条理;类函数
签名;信号
变量;可变物,可变因素
提取;取出
常数
匿名的
嵌套的,内装的
界面;<计>接口;交界面
参数
介绍;引进;提出;采用
压缩
概括
宣布
推断;推论
通用的
参数
创造
移植
脚本
切换
怎么
块
缩进
格式
排序
成员
覆盖
实现
委托
构造函数
模板
控制台
公告
静态
层次结构
匹配
豆子
引用
事件
提交
自动
管理
功能
配置
订阅
门户网站
材料
配置文件
跳过
断点
外部
透视图
定制
导航
表
指定的
终止
删除
滚动
book.txt
edit
refactor
navigate
search
package
revert
refresh
default
convert
line
delimiter
switch
restart
import
export
properties
undo
qualified
paste
select
expand
element
enclosing
previous
incremental
bookmark
mode
insert
tooltip
content
assist
completion
fix
method
signature
variable
extract
constant
anonymous
nested
interface
parameter
introduce
encapsulate
generalize
declared
infer
generic
arguments
create
migrate
script
toggle
comment
block
indentation
format
sort
members
override
inplement
delegate
constructor
template
console
declaration
static
hierarchy
matches
beans
references
occurrences
referring
automatically
dependencies
capabilities
configuration
subscription
portal
material
profile
skip
brakpoint
external
perspective
customize
navigation
sheet
specified
terminated
remove
scroll