Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a[110],t,n,m,i,j,k,temp,p,q;
- char s;
- scanf("%d",&t);
- for(i=1;i<=t;i++){
- scanf("%d %d",&n,&m);
- for(j=0;j<n;j++)
- scanf("%d",&a[j]);
- for(j=0;j<m;j++){
- getchar();
- scanf("%c",&s);
- if(s=='S'){
- scanf("%d",&p);
- for(k=0;k<n;k++)
- a[k]=a[k]+p;
- }
- else if(s=='M'){
- scanf("%d",&p);
- for(k=0;k<n;k++)
- a[k]=a[k]*p;
- }
- else if(s=='D'){
- scanf("%d",&p);
- for(k=0;k<n;k++)
- a[k]=a[k]/p;
- }
- else if(s=='R'){
- for(k=0;k<(n+1)/2;k++){
- temp=a[k];
- a[k]=a[n-(k+1)];
- a[n-(k+1)]=temp;
- }
- }
- else if(s=='P'){
- scanf("%d %d",&p,&q);
- temp=a[p];
- a[p]=a[q];
- a[q]=temp;
- }
- }
- printf("Case %d:\n",i);
- for(j=0;j<n;j++){
- printf("%d",a[j]);
- if(j==(n-1))
- printf("\n");
- else printf(" ");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement