一个小学生做的练习口算的小程序
纯Dev-C++源代码开发
需要密钥:LHlk124lightning
版本:12.0
任何意见评论区见~
Docu.h(在跟源代码一样的目录下新建一个名为Docu.h的文件(后缀.h))代码:
#include<bits/stdc++.h>
#include<windows.h>
#include <stdio.h>
using namespace std;
struct fs {
string nei = " ";
string name="";
string open;
bool lock=0;
} f[100101];
int fnum;
string zhi;
#include<conio.h>
void gotoxy(int x, int y) { // 移动
HANDLE hout; //屏幕尺寸 变量
COORD coord= {x,y}; //光标坐标 变量 光标x标 光标y标
hout=GetStdHandle(STD_OUTPUT_HANDLE); //获得屏幕尺寸
SetConsoleCursorPosition(hout,coord); //移动光标
}
void Opens() {
cout<<"\n-----------------------------------\n";
cout<<"Open:请输入你要打开的文件的名称(不需要加后缀):";
cin>>zhi;
for (int i = 1; i <= fnum; i++) {
if(f[i].name==zhi) {
system("cls");
cout<<"文件编辑(编辑完成输入'|'回车)\n-------------------------------------"<<f[i].nei;
string temp="";
char k;
while(k!='|') {
k=getchar();
temp+=k;
}
f[i].nei=f[i].nei+temp;
}
}
cout<<endl<<"ERROR:未查找到此文件!";
Sleep(0.2*1000);
}
int a[3];
int xs=1;
void newfile() {
system("cls");
cout<<"_____________________________________________________________"<<endl;
cout<<"如果想结束输入就输入'|'符号并回车///正文\n";
string tmp="";
char s=' ';
while(s!='|') {
tmp+=s;
s=getchar();
}
cout<<"------------------------------------";
cout<<endl<<"是否保存?按下Y键确认"<<endl;
if(getch()=='y') {
cout<<"文件名:";
cin>>zhi;
f[fnum].name=zhi;
f[fnum].nei=tmp;
f[fnum].open=".DCMT";
fnum++;
}
}
int Docu () {
system("cls");
cout<<"DocuBook(文档编辑):\n按下N键以新建文档;\n按下S键以打开文档;\n当前文档:\n" ;
for (int i = 0; i <= fnum; i++) {
cout<<f[i].name<<f[i].open;
}
char Do=getch();
if(Do=='n') {
newfile();
} else {
Opens();
}
return 0;
}
以下是源代码(第一篇博客):
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include "Docu.h"
void print(const char* s, int color) {
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
using namespace std;
long long ja, jb, jy, righ, num, l, big, sum, numn;
char fs;
string key, name = "(未登录)",jili="一份努力,一分收获,加油!",pin="LHlk124lightning";
long long no[100100][9], li[100100][9];
char cno[100100], lc[100100], ri[100100];
bool d;
string huancun;
long long kmath=1;
long long ndj=3;
void dd(double a) {
Sleep(a * 1000);
}
string User_key="DKLJFklsdjfa09*ds()J~!@#$%^&*(nnn)";
void ziti() {
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(cfi);
cfi.nFont = 0;
cfi.dwFontSize.X = 0; // Width of each character in the font
cfi.dwFontSize.Y = 24; // Height
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = FW_NORMAL;
std::wcscpy(cfi.FaceName, L"Consolas"); // Choose your font
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
}
int go1() {
for(int i=1; i<=8; i++) {
system("cls");
system("color F8");
cout<<" "<<"{=【|闪电口算登录|】=}"<<endl;
cout<<" "<<" 闪电数学工具包"<<endl;
cout<<" "<<" 按下任意键登录"<<endl;
cout<<" "<<"--------------------"<<endl<<" ";
getch();
cout<<""<<"密钥:";
cin>>zhi;
if(zhi==pin) {
cout<<" "<<"正确!"<<endl;
return 1;
}
}
cout<<"您的密码错误次数已达到上限"<<endl;
return 0;
}
void have(long long k) {
srand((unsigned)time(NULL));
ja = rand() % k + big/2;
jb = rand() % k + big/2;
}
void have2(long long k) {
ja = rand() % k + ndj;
}
long long jiecheng(long long p) {
long long s = 1;
for (long long i = p; i >= 1; i--) {
s *= i;
}
return s;
}
void ksj() {
cout<<"随机数种子附加数值:"<<endl;
cin>>kmath;
cout<<"更改成功!"<<endl;
}
void jisuan() {
system("cls");
long long a,b;
char c;
cin>>a>>c>>b;
if(c=='+') {
cout<<a+b<<endl;
} else if(c=='-') {
cout<<a-b<<endl;
} else if(c=='*') {
cout<<a*b;
} else if(c=='/') {
cout<<a/b<<"……"<<a%b;
}
}
void hide_cursor() { //隐藏光标
HANDLE h_GAME =GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info;
GetConsoleCursorInfo(h_GAME,&cursor_info);
cursor_info.bVisible=false;
SetConsoleCursorInfo(h_GAME,&cursor_info);
}
void jiao() { //教程
system("cls");
cout<<" "<<"按下任意键退出。"<<endl;
cout<<" "<<"+ =加法"<<endl;
cout<<" "<<"- =减法"<<endl;
cout<<" "<<"* =乘法 "<<endl;
cout<<" "<<"/ =除法"<<endl<<"----------------"<<endl;
cout<<" "<<"例:12+13=25"<<endl;
cout<<" "<<" 12"<<endl;
cout<<" "<<" + 13"<<endl;
cout<<" "<<"______"<<endl;
cout<<" "<<" 25"<<endl;
cout<<" "<<"2+3=5 1+1=2"<<endl<<"----------------"<<endl;
cout<<" "<<"例2:13-12=25"<<endl;
cout<<" "<<" 13"<<endl;
cout<<" "<<" + 12"<<endl;
cout<<" "<<"______"<<endl;
cout<<" "<<" 1"<<endl;
cout<<" "<<"1-1=0(在最高位,不写) 3-2=1 "<<endl<<"----------------"<<endl;
cout<<" "<<"例:12*13=25"<<endl;
cout<<" "<<" 12"<<endl;
cout<<" "<<" * 13"<<endl;
cout<<" "<<"______"<<endl;
cout<<" "<<" 36"<<endl;
cout<<" "<<" 12"<<endl;
cout<<" "<<"______"<<endl;
cout<<" "<<" 156"<<endl;
cout<<" "<<"12*3=36 10*12=120(0省略)"<<endl<<" ";
getch();
}
void Do() {
cout<<" "<<"口算:K键"<<endl;
cout<<" "<<"阶乘:J键"<<endl;
cout<<" "<<"错题本:C键"<<endl;
cout<<" "<<"历史记录:L键"<<endl;
cout<<" "<<"修改激励语:X键"<<endl;
cout<<" "<<"登录:D键"<<endl;
cout<<" "<<"教程:T键"<<endl;
cout<<" "<<"用户密码:Y键"<<endl;
cout<<" "<<"DocuBook:O键"<<endl;
cout<<" "<<"Game:G键"<<endl;
cout<<" "<<"退出:P键"<<endl;
}
#include<fstream>
/*
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
fstream f;
f.open("data.txt",ios::out|ios::app);
f<<"今天天气不错"<<endl;
f.close();
return 0;
}
*/
void mainn() {
while(true) {
system("color F3");
system("cls");
cout <<" "<< "_______________________________________ " << endl;
cout <<" "<< "| [闪电口算] [ Lightning speed calculation ] | " << endl;
cout <<" "<< "| 版本:12.0正式版 提供商:闪电Lightning (保留所有权利) 开发者:HJR、LCL | " << endl;
cout <<" "<< "| |"<<" "<<endl;
cout <<" "<< " ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ " << endl;
cout <<" "<< name << "自启动以来练习题目数量:" << sum <<" "<<jili;
cout <<" "<< endl << "#操作表"<<" " <<endl;
Do();
char azhi=getch();
if (azhi == 'k') {
system("cls");
cout <<" "<< "难度(除法只要输入商):"<<endl<<" ";
cin >> big;
cout <<" "<< "题量(输错请输入987654321):"<<endl<<" ";
cin >> l;
system("cls");
int back=num;
for (long long i = 1; i <= l; i++) {
have(big);//赋值
numn++;
if (i % 2 == 1) {
fs = '*';
righ = ja * jb;
} else if (i % 4 == 1) {
fs = '-';
righ = ja - jb;
} else if (i % 5 == 1) {
fs = '/';
righ = ja / jb;
} else {
fs = '+';
righ = ja + jb;
}
/*
-------------------------------------
#问题:
-------------------------------------
@你的回答:
情况:
*/
system("color F9");
cout<<"------------------------------------- \n";
cout<<"问题:";
cout << ja << fs << jb << "=?";
cout<<"\n-------------------------------------\n";
cout<<"你的回答:";
cin >> jy;
cout<<"情况:";
li[numn][1] = ja;
li[numn][2] = jb;
lc[numn] = fs;
if(jy == 987654321) {
break;
} else if (jy == righ) {
sum++;
print("正确YES",2);
ri[numn] = 'Y';
num++;
} else {
sum++;
ri[numn] = 'N';
print("错误NO",4);
num++;
no[num][1] = ja;
no[num][2] = jb;
cno[num] = fs;
no[num][3] = righ;
no[num][4] = jy;
}
dd(1);
system("cls");
}
cout<<"是否导出这次训练?(按下Y键以确定)?"<<endl;
char tmp;
tmp=getch();
if(tmp=='y') {
fstream f;
f.open("口算习题.txt",ios::out|ios::app);
f<<"题量:";
f<<l;
f<<",难度:"<<big;
for (int i =back ;i <= num;i++) {
f<<li[i][1]<<lc[i]<<li[i][2]<<'='<<endl;
}
f<<"-----------------------------"<<endl;
f.close();
}
} else if (azhi == 'j') {//阶乘训练
system("cls");
cout<<"当前是会员内容,请输入你的密码:";
cin>>huancun;
if(huancun==User_key) {
system("cls");
cout<<" " << "题量:";
cin >> l;
cout <<" "<< "难度:";
cin >> big;
system("cls");
for (int i = 1; i <= l; i++) {
have2(big);
cout<<"问题:\n";
cout << ja << "!" << endl;
cout<<"--------------------------\n你的回答:" ;
righ = jiecheng(ja);
cin >> jy;
if (righ == jy)cout << "Yes" << endl;
else {
cout << "No";
}
dd(1);
system("cls");
}
} else {
cout<<"密码错误!";
}
} else if (azhi=='c') {
system("cls");
cout <<" "<< "任意键退出错题本" << endl;
if (num == 0)cout <<" "<< "当前并没有错题~" << endl;
for (int i = 1; i <= num; i++) {
cout <<" "<< "(" << i << ")" << no[i][1] << cno[i] << no[i][2] << "=" << " 正确答案:" << no[i][3] << " 你的答案:" << no[i][4];
cout << endl;
}
getch();
} else if (azhi == 'l'||zhi == "看记录"||zhi == "练习记录") {
system("cls");
cout<<" " << "任意键入退出" << endl;
for (long long i = 1; i <= numn; i++) {
cout <<" "<< li[i][1] << lc[i] << li[i][2] << "=" << " " << ri[i] << endl;
}
getch();
} else if(azhi == 't') {
jiao();
} else if(azhi == 'x') {
system("cls");
if(1+1==2) {
cout<<"如果要进行此操作,请输入你的密码(非闪电口算密钥):";
cin>>huancun;
if(huancun==User_key) {
system("cls");
cout<<" "<<"请输入激励语:"<<endl;
cin>>jili;
cout<<" "<<"修改成功!" ;
dd(1);
} else {
cout<<"密码错误!";
}
}
} else if (azhi == 'd') {
system("cls");
cout <<" "<< "密钥:" ;
cin >> key;
if (key == "2012lhlightning"||key=="LH123"||key == "lightningshandian.com"||key == "LHlk124lightning") {
dd(1);
cout <<" "<< "登录成功!" ;
d=1;
cout <<"\n "<< "用户名:";
cin >> name;
cout<<"\n "<<"请输入你的密码:";
cin>>User_key;
} else {
cout <<" "<< "密钥错误!" << endl;
dd(1);
}
} else if (azhi == 'p') {
cout<<"确定要退出吗?(按下q确定)";
if(getch()=='q') {
cout <<" "<< "感谢使用!退出" << endl;
return ;
}
} else if(zhi=="counter") {
jisuan();
} else if(zhi=="ndcalculation") {
if(d==1) {
ksj();
} else {
cout<<"请登录闪电口算,否则无法进行个性化设置。";
}
} else if(zhi=="nd/jiecheng") {
if(d==1) {
cout<<"如果要进行此操作,请输入你的密码:";
cin>>huancun;
if(huancun==User_key) {
system("cls");
cout<<"阶乘难度附加值:";
cin>>ndj;
cout<<"更改成功!";
dd(1);
} else {
cout<<"密码错误!";
}
} else {
cout<<"请登录闪电口算,否则无法进行个性化设置。"<<endl;
}
} else if(zhi=="color") {
cin>>zhi;
if(zhi=="E1") {
system("color E1");
} else if(zhi=="F4") {
system("color F4");
} else if(zhi=="F3") {
system("color F3");
} else if(zhi=="F5") {
system("color F5");
} else if(zhi=="F6") {
system("color F6");
} else if(zhi=="E7") {
system("color E7");
} else if(zhi=="F1") {
system("color F1");
} else if(zhi=="F2") {
system("color F2");
} else if(zhi=="E5") {
system("color E5");
} else if(zhi=="E9") {
system("color E9");
} else {
cout<<"No color!";
dd(1);
}
} else if(azhi=='y') {
system("cls");
cout<<"请输入原来的密码";
cin>>zhi;
if(zhi=="LHlk124lightning") {
cout<<"请输入修改后的密码"<<endl;
cin>>pin;
cout<<"请再输入一遍!"<<endl;
cin>>zhi;
if(zhi==pin) {
cout<<" "<<"已退出登录"<<endl;
go1();
} else {
cout<<" "<<"修改后的密码与输入的密码不匹配!"<<endl;
}
} else {
cout<<" "<<"原密码错误!"<<endl;
}
} else if(zhi=="z") {
// go1();
} else if(azhi=='o') {
Docu();
} else if(azhi=='g'){
}
system("cls");
}
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {
char wtitle[512];
GetWindowText(hwnd, wtitle, sizeof(wtitle));
if (strstr(wtitle , "Visual Studio")) {
::SendMessage(hwnd, WM_CLOSE, 0, 0);
}
return (true);
}
int main() {
ziti();
system("color F5");
if(go1()==1) {
system("color F9");
mainn();
dd(1);
system("cls");
cout << "正在退出" << endl;
EnumWindows(EnumWindowsProc,0);
dd(2);
system("cls");
}
system("pause");
return 0;
}
//闪电科技公司<闪电Lightning> 版权所有,严禁复制,修改!
//HJR 、 LCL 的忠告。
禁止盗版!!!
运行的话
直接粘贴编译就可以了。