1、C语言初学小程序/本程序在Windows 64位VC+6.0环境下运行有效,运行/前请下载安装easyx库这是主菜单效果图#include /图形函数头文件#include#include #include #include#include#include#include#include#define PI 3.14159265#define MAXSTAR 200 / 星星总数(画星星)struct STAR/画星星的全体变量 double x; int y; double step; int color;/一个星空界面的数据结构STAR starMAXSTAR;/ 初始化星星void In
2、itStar(int i) stari.x = 0; stari.y = rand() % 480; stari.step = (rand() % 5000) / 1000.0 + 1; stari.color = (int)(stari.step * 255 / 6.0 + 0.5); / 速度越快,颜色越亮 stari.color = RGB(stari.color, stari.color, stari.color);void stars();/画星星啊void xing();/心型void diamond();/绘制静态钻石图案void arrow();/画一只箭头void ziqi(
3、);/写入开机自启void andriod();/画一个安卓图案void siyecao();/画一朵四叶草void baidu();/XX搜索引擎void password();/void kill();/杀死进程void welcome();/void goodbye();/void zimu();/打字母游戏void sd();/指定时间关闭指定进程void initStar();/初始化星星void color()printf(更改程序颜色n);printf(背景颜色 字体颜色n);printf(0 = 黑色 8 = 灰色 n);printf(1 = 蓝色 9 = 淡蓝色 n);pri
4、ntf(2 = 绿色 A = 淡绿色 n);printf(3 = 浅绿色 B = 淡浅绿色 n);printf(4 = 红色 C = 淡红色 n);printf(5 = 紫色 D = 淡紫色 n);printf(6 = 黄色 E = 淡黄色 n);printf(7 = 白色 F = 亮白色 n);printf( n);void picmenu() printf( n);printf(C语言程序n);printf(7.输出心型图案 n);printf(8.画星星 n);printf(A.画一个箭头 n);printf(B.绘制钻石图案 n);printf(D.画一个安卓机器人 n);printf
5、(E.画一朵四叶草 n);printf(Q.返回主菜单 n);printf( n);void menu()/主菜单printf( n);printf(C语言程序n);printf(1.命令提示符 n);printf(2.小游戏 n);printf(3.更改背景及字体颜色 n);printf(4.打开注册表 n);printf(5.打开记事本 n);printf(6.查询本机IP地址 n);printf(7.系统类 n);printf(8.XX搜索引擎 n);printf(9.文件加密 n);printf(P.输出有趣图案 n);printf(G.定时关机、注销计算机 n);printf(Q.退
6、出系统 n);printf(n);void xitong()/系统类菜单printf( n);printf(C语言程序n);printf(8.修改系统密码 n);printf(A.列出系统进程 n);printf(B.强行结束系统进程 n);printf(U.将U盘格式转化为NTFS n);printf(C.将程序写入开机自启 n);printf(D.计算器 n);printf(E.截图 n);printf(F.指定时间关闭指定程序 n);printf(Q.返回主菜单 n);printf(n);void main()/主函数system(title C语言程序-王熠);/设置cmd窗口标题sy
7、stem(mode con cols=45 lines=1000);/窗口宽度高度system(color 0C);/窗口颜色system(date /T);/系统时间system(TIME /T);char cmd20=shutdown -s -t ;/关机指令char mima30=net user administrator ;/修改系统密码指令char t5=0;/自定义关机时间char s7=0;/自定义密码char ch;p: menu();printf(请输入选项(小写状态下请按enter执行命令):n);ch=getch();printf(%cn,ch);while(ch!=)
8、 if(ch=G|ch=g) printf( n); printf( 关机 n); printf(1.实现10分钟内的定时关闭计算机 n); printf(2.立即关闭计算机 n); printf(3.重启计算机 n); printf(4.取消关机 n); printf(Q.返回主菜单 n); printf(n); ch=getch(); printf(%cn,ch); while(ch!=) if(ch=1) printf(你想在多少秒后自动关闭计算机?(0600)n); scanf(%s,t); system(strcat(cmd,t); printf(请继续选择操作:n); ch=get
9、ch(); printf(%cn,ch); else if(ch=2) system(shutdown -p); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=3) system(shutdown -r -t 0); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=4) system(shutdown -a); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=Q|ch=q) goto p;
10、else printf(输入错误,请重新输入:n); ch=getch(); printf(%cn,ch); else if(ch=1) system(cmd); else if(ch=2) printf(1.打字母游戏n); printf(Q.返回主菜单n); ch=getch(); printf(%cn,ch);while(ch!=) if(ch=Q|ch=q) goto p; if(ch=1) zimu(); else printf(输入有误,请重新输入:n); ch=getch(); printf(%cn,ch); else if(ch=3) char yanse8=color ; c
11、har m3=0; char n3=0; color(); printf(请选择背景色,按enter键结束:n); scanf(%s,m); printf(请选择前景色,按enter键结束:n); scanf(%s,n); system(strcat(yanse,strcat(m,n); menu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=4) system(regedit.exe); menu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch
12、=5) system(notepad); menu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=6) system(ipconfig); menu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=7) xitong(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); while(ch!=) if(ch=8) printf(请输入密码(仅改变系统管理员账号administrator密码):n); s
13、canf(%s,s); system(strcat(mima,s); xitong(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=A|ch=a) system(tasklist); printf(请继续选择操作:n); xitong(); ch=getch(); printf(%cn,ch); else if(ch=B|ch=b) kill(); printf(请继续选择操作:n); xitong(); ch=getch(); printf(%cn,ch); else if(ch=U|ch=u) char geshi1
14、=convert ; char geshi2=: /fs:ntfs; char ee2=0; printf(请输入U盘所在的盘符(按enter键执行):n); scanf(%s,ee); printf(文件系统格式转化中n); system(strcat(strcat(geshi1,ee),geshi2); xitong(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=C|ch=c) ziqi(); xitong(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else
15、 if(ch=D|ch=d) system(calc); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=E|ch=e) system(SnippingTool.exe); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=F|ch=f) sd(); xitong(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=Q|ch=q) goto p; else MessageBox(NULL,您输
16、入的选项不正确,请重新输入,煌羽,MB_OK); ch=getch(); printf(%cn,ch); else if(ch=8) baidu(); menu(); printf(请继续选择操作:n); ch=getch(); printf(%cn, ch); else if(ch=9) printf(1.文件加密or解密nn); password(); menu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=P|ch=p) picmenu(); ch=getch(); printf(%cn,ch); while(c
17、h!=) /图案中的while括号 if(ch=7) xing(); picmenu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=8) stars(); picmenu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=A|ch=a) arrow(); picmenu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=B|ch=b) diamond(); picmenu();
18、 printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=D|ch=d) andriod(); picmenu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=E|ch=e) siyecao(); picmenu(); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); else if(ch=Q|ch=q) goto p; else MessageBox(NULL,您输入的选项不正确,请重新输入,煌羽,MB_OK); c
19、h=getch(); printf(%cn,ch); /图案中的while括号/else if 图案的括号 else if(ch=Q|ch=q) exit(0); else MessageBox(NULL,您输入的选项不正确,请重新输入,煌羽,MB_OK); printf(请继续选择操作:n); ch=getch(); printf(%cn,ch); void kill()char task=taskkill /f /t /im ; char kill=0; printf(请输入进程名或者相应PID:n); scanf(%s,kill); system(strcat(task,kill); v
20、oid welcome() / 输出屏幕提示 cleardevice(); setcolor(RED); setfont(64, 0, 黑体); outtextxy(160, 50, 打字母游戏); setcolor(WHITE); setfont(16, 0, 宋体); outtextxy(100, 200, 就是很传统的那个掉字母然后按相应键就消失的游戏); outtextxy(100, 240, 只是做了一个简单的实现); outtextxy(100, 280, 功能并不很完善,比如生命数、分数等都没有写); outtextxy(100, 320, 感兴趣的自己加进去吧); / 实现闪烁
21、的“按任意键继续” int c=255; while(!kbhit() setcolor(RGB(c, 0, 0); outtextxy(280, 400, ); c -= 8; if (c 0) c = 255; Sleep(20); getch(); cleardevice();/ 退出界面void goodbye() cleardevice(); setcolor(YELLOW); setfont(48, 0, 黑体); outtextxy(104, 180, 多写程序 不老青春); getch();/ 主函数void zimu() void welcome(); void goodby
22、e(); initgraph(640, 480); / 初始化屏幕为 640x480 welcome(); / 显示欢迎界面 srand(time(NULL); / 设置随机种子 setfont(16, 0, Arial); / 设置字母的字体和大小 setfillstyle(RED); / 设置清除字母的填充区域颜色 char target; / 目标字母 char key; / 用户的按键q: int x, y=0; / 字母的位置 / 主循环 while(y=458) target = 65 + rand() % 26; / 产生任意大写字母,先产生025之间的随机数。 x = rand() % 620; / 产生任意下落位置,窗口最大长度620 for (y=0; ynul; printf(请输入想要关闭的程序名:n); scan
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1