基础知识 线性表

推荐题目

【数据结构1-1】线性表(from 洛谷)(●'◡'●)icon-default.png?t=N7T8https://www.luogu.com.cn/training/113

P3156 【深基15.例1】询问学号

P3156 【深基15.例1】询问学号(from 洛谷)(●'◡'●)icon-default.png?t=N7T8https://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 洛谷)(●'◡'●)icon-default.png?t=N7T8https://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 洛谷)(●'◡'●)icon-default.png?t=N7T8https://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;
}

THE END

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值