标签:
水题,主要是学习文件输入输出。
1 /* 2 ID: ijustwa1 3 LANG: C++ 4 TASK: ride 5 */ 6 #include<cstdio> 7 #include<cstring> 8 9 using namespace std; 10 11 const int base=16; 12 const int mod=47; 13 14 char s[10]; 15 char t[10]; 16 17 int main() 18 { 19 FILE *fin=fopen("ride.in","r"); 20 FILE *fout=fopen("ride.out","w"); 21 22 fscanf(fin,"%s",s); 23 fscanf(fin,"%s",t); 24 int sums=1; 25 int sumt=1; 26 for(int i=0;s[i]!=‘\0‘;i++) 27 { 28 sums*=(s[i]-‘0‘-base); 29 } 30 sums%=mod; 31 for(int i=0;t[i]!=‘\0‘;i++) 32 { 33 sumt*=(t[i]-‘0‘-base); 34 } 35 sumt%=mod; 36 37 if(sums==sumt) 38 { 39 fprintf(fout,"GO\n"); 40 //fprintf(stdout,"GO\n"); 41 } 42 else 43 { 44 fprintf(fout,"STAY\n"); 45 //fprintf(stdout,"STAY\n"); 46 } 47 return 0; 48 }
标签:
原文地址:http://www.cnblogs.com/-maybe/p/4738068.html