Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stack>
- #include<stdio.h>
- using namespace std;
- int cur=1, dra=0;;
- int main(){
- string s;
- string ans="";
- int n, m;
- cin>>s>>n>>m;
- string c="";
- for(int i=0;i<=s.size();i++){
- if(i==s.size() || s[i]==','){
- if(dra==0){
- if(cur==n+1){
- dra=1;
- cur=2;
- }
- else { ans+=c; ans+=',';cur++;}
- }else{
- if(cur==m+1){
- cur=2;
- dra=0;
- ans+=c;ans+=',';
- }else{
- cur++;
- }
- }
- c="";
- }else { c+=s[i];}
- }
- for(int i=0;i<ans.size()-1;i++)cout<<ans[i];
- if(ans[ans.size()-1]!=',')cout<<ans[ans.size()-1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement