Advertisement
erfanul007

LOJ 1133

Apr 14th, 2021
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int a[110],t,n,m,i,j,k,temp,p,q;
  5.     char s;
  6.     scanf("%d",&t);
  7.     for(i=1;i<=t;i++){
  8.         scanf("%d %d",&n,&m);
  9.         for(j=0;j<n;j++)
  10.             scanf("%d",&a[j]);
  11.         for(j=0;j<m;j++){
  12.             getchar();
  13.             scanf("%c",&s);
  14.             if(s=='S'){
  15.                 scanf("%d",&p);
  16.                 for(k=0;k<n;k++)
  17.                     a[k]=a[k]+p;
  18.             }
  19.             else if(s=='M'){
  20.                 scanf("%d",&p);
  21.                 for(k=0;k<n;k++)
  22.                     a[k]=a[k]*p;
  23.             }
  24.             else if(s=='D'){
  25.                 scanf("%d",&p);
  26.                 for(k=0;k<n;k++)
  27.                     a[k]=a[k]/p;
  28.             }
  29.             else if(s=='R'){
  30.                 for(k=0;k<(n+1)/2;k++){
  31.                     temp=a[k];
  32.                     a[k]=a[n-(k+1)];
  33.                     a[n-(k+1)]=temp;
  34.                 }
  35.             }
  36.             else if(s=='P'){
  37.                 scanf("%d %d",&p,&q);
  38.                 temp=a[p];
  39.                 a[p]=a[q];
  40.                 a[q]=temp;
  41.             }
  42.  
  43.         }
  44.         printf("Case %d:\n",i);
  45.         for(j=0;j<n;j++){
  46.             printf("%d",a[j]);
  47.             if(j==(n-1))
  48.                 printf("\n");
  49.             else printf(" ");
  50.         }
  51.     }
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement