Dev-C++自制小程序:ASCII码表
软件地址:https://sourceforge.net/projects/orwelldevcpp/
代码:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
long long i,j=1,cnt=0; //声明变量
void show(int n,char c,bool f) //自定义函数,括号里n表示次数,c表示要输出的东西,f表示是否换行
{
for(j=1;j<=n;j++)cout<<c; //输出指定字符
if(f) cout<<'\n'; //这里简写,全写:if(f==1)
}
int main()
{
HWND hwnd=GetForegroundWindow(); //获取当前窗口,(第12~15行的内容可以省略)
system("mode con cols=91 lines=51"); //设置窗口大小
int a=MessageBox(NULL,"置顶?","ASCII码表",36); //自定义弹窗 if(a==6)SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); //如果需要置顶,那么置顶
show(91,'-',true); //使用自定义函数:输出91次字符'-',需要换行
printf("|\t\t\t\t\tASCII表"); //标题
show(43,' ',false); //使用自定义函数:输出43次字符' '(空格),不需要换行
printf("|\n"); //\n表示换行
show(91,'-',true);
for(i=1;i<=22;i++)
{
printf("|");
for(j=1;j<=6;j++)
{
cout<<" "<<cnt<<" |"<<" "<<(char)cnt<<" "<<"|"; //先输出序号,再输出字符
if(cnt==128)cout<<"共计127个,128非字符,129为string非正常结束现象|"; //可以省略不写
cnt++; //计数+1
}
cout<<'\n'; //换行
show(91,'-',true);
}
while(1) //UP只会这样写……
{}
}