📄 1.cpp
字号:
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
map<string ,int> table;
vector< pair<int ,string> > out_vect;
const int cong = 91;
const int digit = 70;
// 判断是否是数字串
bool isdigit( string tmp )
{
return tmp[0] >= '0' && tmp[0] <= '9';
}
// 数字串到十进制的转换
int string_to_dec( string tmp )
{
int ans = 0;
for( int i = 0; i < tmp.size(); ++i ){
ans = 10 * ans + ( tmp[i] - '0' );
}
return ans ;
}
//dec to binary string
string dec_to_binstr( int tmp )
{
string ans = "";
if( tmp == 0 )
return "0";
while( tmp > 0 ){
ans = char( tmp % 2 + '0' ) + ans;
tmp /= 2;
}
return ans ;
}
bool out_put()
{
for( int i = 0; i < out_vect.size(); ++i ){
cout << "( " << out_vect[i].first << " , "
<< out_vect[i].second << " )" << endl;
}
}
int main()
{
freopen("in.cpp" ,"r",stdin );
freopen("out.txt", "w", stdout );
// 关键字的输入 处理 生成 Table 表格
{
ifstream fin("Token.txt");
string tmp;
int tt = 0;
while( fin >> tmp ){
table[tmp] = ++tt;
}
}
// system("pause");
out_vect.clear();
{
string tmp;
while( cin >> tmp ){
// cout << tmp << endl; // debug
if( tmp == "int" ){
pair<int, string> tt;
tt.first = table[ tmp ];
tt.second = "";
out_vect.push_back( tt );
break;
}
}
}
// 一次读入一个在文件中的字符串 然后在这个字符串上进行操作,
// 首先分离这个串,存到vector数组里面,然后进行分别处理。
//由于界符里面没有下划线这个符号因此我们在这里完全可以省略掉很多测试
{
string input_string;
while( cin >> input_string ){
// cout << input_string << endl; // debug
string & in_this = input_string ; // 对输入串另起名字
vector<string> vect_str; // 储存修改后的串
{
string tmp = "";
int i = 0;
while( i < in_this.size() ){
// 第一个条件:说明这是一个字符串
// 这个字符串在语言中可以是关键字,也可以是变量,
// 在这里我们要求关键字全部使用小写。我排除了大写这个情况希望在以后的修改中我可以加上
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -