标签:des style class blog c code
4 4 FIFO IN 1 IN 2 OUT OUT 4 FILO IN 1 IN 2 OUT OUT 5 FIFO IN 1 IN 2 OUT OUT OUT 5 FILO IN 1 IN 2 OUT IN 3 OUT
1 2 2 1 1 2 None 2 3
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 5 int main() 6 { 7 int N,FIFO,FILO,b[100000],i,j,T,sign[10000],sum; 8 scanf("%d",&N); 9 while(N--) 10 { 11 scanf("%d%s",&T,sign); 12 if(strcmp(sign,"FIFO")==0) 13 { 14 i=0; 15 j=0; 16 while(T--) 17 { 18 scanf("%s",sign); 19 if(strcmp(sign,"IN")==0) 20 { 21 scanf("%d",&b[i]); 22 i++; 23 } 24 else if(strcmp(sign,"OUT")==0) 25 { 26 if(i==j) 27 { 28 printf("None\n"); 29 continue; 30 } 31 printf("%d\n",b[j]); 32 j++; 33 } 34 35 } 36 } 37 else if(strcmp(sign,"FILO")==0) 38 { 39 i=0; 40 j=0; 41 while(T--) 42 { 43 scanf("%s",sign); 44 if(strcmp(sign,"IN")==0) 45 { 46 scanf("%d",&b[i]); 47 i++; 48 } 49 else if(strcmp(sign,"OUT")==0) 50 { 51 if(i==0) 52 { 53 printf("None\n"); 54 continue; 55 } 56 i--; 57 printf("%d\n",b[i]); 58 } 59 } 60 } 61 } 62 return 0; 63 }
ACboy needs your help again!,布布扣,bubuko.com
标签:des style class blog c code
原文地址:http://www.cnblogs.com/LWF5201314614/p/3750316.html