zhangfengkai001 @ 2024-10-04 23:06:51
#include <iostream>
#include <string>
#include <map>
using namespace std;
const string in = "int";
const string put = "cout";
map<string, int> dmp;
int dd = 0;
int ddmp[100][1000000];
int dds[100];
struct ddrt
{
int v;
bool yc;
};
inline int makd(string s)
{
short l = s.size();
int px = 1;
int turn = 0;
for (int i = l - 1; i >= 0; i--)
{
turn += (s[i] - '0') * px;
px *= 10;
}
return px;
}
int trds(string s)
{
string ddnr = "";
int nzb;
for (int i = 0;; i++)
{
if (s[i] == '[')
{
nzb = i + 1;
break;
}
ddnr += s[i];
}
string dddr = "";
int ddh = dmp[ddnr];
for (int i = nzb; i < s.size(); i++)
{
if (s[i] != ']')
{
if (dddr[i - 1] <= '9' && dddr[i - 1] >= '0')
{
int mdd = makd(dddr);
if (dds[ddh] < mdd)
{
cout << "-1";
exit(0);
}
return ddmp[ddh][makd(dddr)];
}
break;
}
else
{
return trds(dddr);
}
dddr += s[i];
}
}
void putdindex(string s, int v)
{
string ddnr = "";
int nzb;
for (int i = 0;; i++)
{
if (s[i] == '[')
{
nzb = i + 1;
break;
}
ddnr += s[i];
}
string dddr = "";
int ddh = dmp[ddnr];
for (int i = nzb; i < s.size(); i++)
{
if (s[i] != ']')
{
if (dddr[i - 1] <= '9' && dddr[i - 1] >= '0')
{
int mdd = makd(dddr);
if (dds[ddh] < mdd)
{
cout << "-1";
exit(0);
}
ddmp[ddh][makd(dddr)] = v;
return;
}
break;
}
else
{
putdindex(dddr,v);
}
dddr += s[i];
}
}
int main()
{
string kw;
string nw;
while (cin >> kw)
{
cin >> nw;
if (kw == in)
{
cout<<"I read int.";
string dn;
string ds;
short lon;
for (int i = 0; i < nw.size(); i++)
{
if (nw[i] != '[')
{
dn += nw[i];
}
else
{
lon = i;
break;
}
}
dmp[dn] = dd++;
for (int i = lon; i < nw.size(); i++)
{
if (nw[i] != ']')
{
ds += nw[i];
}
else
{
dds[dmp[dn]] = trds(ds);
}
}
}
else if (kw == put)
{
int v= trds(nw);
cout << v << '\n';
}
else
{
putdindex(kw, trds(nw));
}
}
return 0;
}
看看吧,有用送《渡口》无损音源!!!
by zhangfengkai001 @ 2024-10-04 23:09:47
@cjy100
@zhaoyiling2023
by cjy100 @ 2024-10-05 09:42:19
@zhangfengkai001 你124行是什么东西
by cjy100 @ 2024-10-05 09:46:55
@zhangfengkai001 第128行nw.size()应是nw.size()-1
by zhangfengkai001 @ 2024-10-05 10:53:52
@cjy100 124是调试
by zhaoyiling2023 @ 2024-10-05 11:59:26
@zhangfengkai001 我要《Never Gonna Give You up》的谢谢(鞠躬
by zhangfengkai001 @ 2024-10-05 13:44:45
@zhaoyiling2023
彳亍
by zhaoyiling2023 @ 2024-10-06 08:02:24
@zhangfengkai001 好的!但是我懒得帮你看(微笑
by cjy100 @ 2024-10-06 10:06:20
@zhangfengkai001 我觉得你的代码是chatGPT给的
by zhangfengkai001 @ 2024-10-06 10:57:25
@cjy100 bushi
by zhangfengkai001 @ 2024-10-06 10:58:28
@zhaoyiling2023 :(