zhangfengkai001 @ 2024-10-12 13:30:54
#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];
bool impt_tf=0;
//int find_last(string s,char c)
//{
// for(int i=s.size()-1;i>=0;i--)
// {
// if(s[i]==c)
// {
// return i;
// }
// }
// return -1;
//}
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;
}
inline bool isitd(string s)
{
for(int i=0;i<s.size();i++)
{
if(!s[i]<='9' || !s[i]>='0')
{
return 0;
}
}
return 1;
}
inline void RE ()
{
cout<<-1;
exit(0);
}
int find_did(string s)
{
int d=s.find('[');
string ddname=s.substr(0,d-1);
int ddnum=dmp[ddname];
if(isitd(s))
{
return ddmp[ddnum][makd(s)];
}
int l=s.size();
int n=l-1;
string next=s.substr(d-1,n);
if(ddmp[ddnum][find_did(next)]<dds[ddnum])
return ddmp[ddnum][find_did(next)];
impt_tf=1;
RE();
return -114514;
}
int main()
{
string kw;
string nw;
while (cin >> kw)
{
cin >> nw;
if (kw == in)
{
int wzmm=nw.find('[')-1;
string ddn=nw.substr(0,wzmm);
dmp[ddn]=dd;
string inputstr=nw.substr(wzmm,nw.size()-1);
int imptd=find_did(inputstr);
dds[dd]=imptd;
dd++;
}
else if (kw == put)
{
int wzmm=nw.find('[')-1;
string ddn=nw.substr(0,wzmm);
string inputstr=nw.substr(wzmm,nw.size()-1);
cout << find_did(inputstr) << '\n';
}
else
{
int wzmm=kw.find('[')-1;
string ddn=kw.substr(0,wzmm);
string inputstr=nw.substr(wzmm,kw.size()-1);
int imptd=find_did(inputstr);
ddmp[dmp[kw]][imptd]=makd(nw);
}
}
return 0;
}
RERERE!
看看吧,有用送 《渡口》 + 《The truth that you leave - Pianoboy》 无损音源!!!
by Estrella_Explore @ 2024-10-12 13:40:21
所有编译警告如下:
./test.cpp: In function ‘int makd(std::string)’:
./test.cpp:30:21: 警告:conversion from ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} to ‘short int’ may change value [-Wconversion]
30 | short l = s.size();
| ~~~~~~^~
./test.cpp: In function ‘bool isitd(std::string)’:
./test.cpp:41:23: 警告:comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
41 | for (int i = 0; i < s.size(); i++) {
| ~~^~~~~~~~~~
./test.cpp:42:19: 警告:logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
42 | if (!s[i] <= '9' || !s[i] >= '0') {
| ^~
./test.cpp:42:13: 附注:add parentheses around left hand side expression to silence this warning
42 | if (!s[i] <= '9' || !s[i] >= '0') {
./test.cpp:42:19: 警告:comparison of constant ‘'9'’ with boolean expression is always true [-Wbool-compare]
42 | if (!s[i] <= '9' || !s[i] >= '0') {
| ~~~~~~^~~~~~
./test.cpp:42:35: 警告:logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
42 | if (!s[i] <= '9' || !s[i] >= '0') {
| ^~
./test.cpp:42:29: 附注:add parentheses around left hand side expression to silence this warning
42 | if (!s[i] <= '9' || !s[i] >= '0') {
./test.cpp:42:35: 警告:comparison of constant ‘'0'’ with boolean expression is always false [-Wbool-compare]
42 | if (!s[i] <= '9' || !s[i] >= '0') {
| ~~~~~~^~~~~~
./test.cpp: In function ‘int find_did(std::string)’:
./test.cpp:55:19: 警告:conversion from ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]
55 | int d = s.find('[');
| ~~~~~~^~~~~
./test.cpp:61:19: 警告:conversion from ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]
61 | int l = s.size();
| ~~~~~~^~
./test.cpp: In function ‘int main()’:
./test.cpp:77:37: 警告:conversion from ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]
77 | int wzmm = nw.find('[') - 1;
| ~~~~~~~~~~~~~^~~
./test.cpp:85:37: 警告:conversion from ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]
85 | int wzmm = nw.find('[') - 1;
| ~~~~~~~~~~~~~^~~
./test.cpp:90:37: 警告:conversion from ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} to ‘int’ may change value [-Wconversion]
90 | int wzmm = kw.find('[') - 1;
| ~~~~~~~~~~~~~^~~
by Estrella_Explore @ 2024-10-12 13:42:52
猜你想要:
line 42 之前的修改,后面不会改
inline int makd(string s) {
int 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;
}
inline bool isitd(string s) {
for (int i = 0; i < s.size(); i++) {
if (!(s[i] <= '9') || !(s[i] >= '0')) {
return 0;
}
}
return 1;
}
by zhangfengkai001 @ 2024-10-14 16:25:37
@Estrella_Explore 谢谢
by zhangfengkai001 @ 2024-10-14 16:26:37
@Estrella_Explore 私Q发音源。