推荐题目
【数据结构1-1】线性表(from 洛谷)(●'◡'●)https://www.luogu.com.cn/training/113
P3156 【深基15.例1】询问学号
P3156 【深基15.例1】询问学号(from 洛谷)(●'◡'●)https://www.luogu.com.cn/problem/P3156
#include<bits/stdc++.h>
using namespace std;
int a[2000010];
int n,m,sum;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=m;i++){
cin>>sum;
cout<<a[sum]<<endl;
}
}
P3613 【深基15.例2】寄包柜
P3613 【深基15.例2】寄包柜(from 洛谷)(●'◡'●)https://www.luogu.com.cn/problem/P3613
#include<bits/stdc++.h>
using namespace std;
int n,q,p,k;
map<long long,int>b;
long long i,j;
int main(){
cin>>n>>q;
while(q--){
cin>>p>>i>>j;
if(p==1){
cin>>k;
b[i*1000000+j]=k;
}
else cout<<b[i*1000000+j]<<endl;
}
return 0;
}
P1449 后缀表达式
P1449 后缀表达式(from 洛谷)(●'◡'●)https://www.luogu.com.cn/problem/P1449
#include<bits/stdc++.h>
using namedpace std;
stack<int> q;
string c;
int main(){
cin>>c;
int a=0,b=0;
int i,j;
for(int k=0;k<c.length();k++){
if(c[k]=='@')
break;
else if(c[k]=='.'){
q.push(a);
a=0;
b=0;
}
else if(c[k]<='9'&&c[k]>='0'){
a=b*10+c[k]-'0';
b=a;
}
else{
if(c[k]=='-'){
i=q.top();
q.pop();
j=q.top();
q.pop();
q.push(j-i);
}
else if(c[k]=='+'){
i=q.top();
q.pop();
j=q.top();
q.pop();
q.push(j+i);
}
else if(c[k]=='*'){
i=q.top();
q.pop();
j=q.top();
q.pop();
q.push(j*i);
}
else if(c[k]=='/'){
i=q.top();
q.pop();
j=q.top();
q.pop();
q.push(j/i);
}
}
}
cout<<q.top()<<endl;
}