标签:def char NPU == 格式 for eof har filename
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define rep(i,a,b) for(int i=a;i<=b;++i) 4 #define ms(arr,a) memset(arr,a,sizeof arr) 5 bool isfile(char s[]) 6 { 7 if(strstr(s,".txt"))return true; 8 return false; 9 } 10 bool isint(char s[]) 11 { 12 int sz=strlen(s); 13 rep(i,0,sz-1) 14 { 15 if(s[i]==‘(‘||s[i]==‘[‘)return true; 16 } 17 return false; 18 } 19 bool ismul(char s[]) 20 { 21 int sz=strlen(s); 22 rep(i,0,sz-1) 23 { 24 if(s[i]==‘*‘)return true; 25 } 26 return false; 27 } 28 int main() 29 { 30 freopen("Input.txt","w",stdout); 31 srand((unsigned)time(NULL)); 32 char in[1000]; 33 char filename[1000]="Input.txt"; 34 while(~scanf("%s",in)) 35 { 36 if(isfile(in))freopen(in,"w",stdout); 37 else if(isint(in)) 38 { 39 int l,r,times=1; 40 char lp,rp; 41 if(ismul(in))sscanf(in,"%c%d,%d%c*%d",&lp,&l,&r,&rp,×); 42 else sscanf(in,"%c%d,%d%c",&lp,&l,&r,&rp); 43 if(lp==‘(‘)l++; 44 if(rp==‘)‘)r--; 45 if(r<l)l=r=0; 46 rep(i,1,times) 47 { 48 if(l==r)printf("%d ",l); 49 else printf("%d ",rand()%(r-l)+l); 50 } 51 printf("\n"); 52 } 53 else printf("%s\n",in); 54 } 55 }
标签:def char NPU == 格式 for eof har filename
原文地址:https://www.cnblogs.com/maoruimas/p/9521128.html