1.慢慢出字
C++#include<iostream> //#include<cstdio>
#include<windows.h>
#include<string>
using namespace std;
void cz(string nr,double speed)
{
for(int i=0;i<nr.size();i++) //for(int i=0;i<nr.length();i++)
{
cout<<nr[i]; //printf("%c",nr[i]);
Sleep(speed*1000);
}
}
int main()
{
//演示:
cz("yeejiansanlian",0.114);
return 0;
}
2.保存文件
C++#include<iostream> //#included<cstdio>
#include<fstream>
using namespace std;
ofstream hor;
fstream net;
void cc(int &yee) //存储
{
hor.open("super.txt");
hor<<yee;
hor.close();
}
void dq(int &yee) //读取
{
net.open("super.txt");
net>>yee;
net.close();
}
int main()
{
int a;
dq(a);
cout<<a;
cin>>a;
cc(a);
}
改字与背景
C++#include <bits/stdc++.h>
#include <windows.h>//神秘的头文件
using namespace std;//标准命名空间
void SetColorAndBackground (int ForgC,int BackC)
{
WORD wColor=((BackC & 0x0f)<<4)+(ForgC & 0x0f);
SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE),wColor);
}
int main ()//主函数
{
//1.整体改变
system ("color 0F");//背景先颜色后
//2.按自己改变某处
SetColorAndBackground (15,0);//推荐字背景与屏幕背景相同
//cout<<1;
return 0;//返回0
}
//代码长度:
/*
颜色数字和字母
0黑色1蓝色2绿色3浅绿色
4红色5紫色6黄色7白色
8灰色9浅蓝色A淡绿色B淡浅绿色
C淡红色D淡紫色E淡黄色F亮白色
*/
电脑没电了先写到这,关注快更