Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我快死了,救救我的程序,(附)(救人一命,胜造七级浮屠)#include <iostream.h> #include <string.h> int n,k; int q[200],up,w[200];//up 表示天平不平了几次 int main() { memset(q,0,sizeof(q)); memset(w,0,sizeof(w)); cin>>n; flag=1;up=0; int i; for (i=1;i<=n;i++) { for (k=1;k<=3;k++) { int j; int temp[200];char st[200]; int p;memset(temp,0,sizeof(temp)); cin>>st;p=strlen(st); for (j=0;j<=p-1;j++) temp[j+1]=st[j]-'A'+1; cin>>st; for (j=0;j<=p-1;j++) temp[j+1+p]=st[j]-'A'+1; char ch[10]; cin>>ch; if (!strcmp(ch,"even")) { for (j=1;j<=p*2;j++) q[temp[j]]=-1; } else { flag=0;up++; for (j=1;j<=p*2;j++) if (q[temp[j]]!=-1) { q[temp[j]]++; if (!strcmp(ch,"up")) { if (j>p) w[temp[j]]=-1; else w[temp[j]]=+1; } if (!strcmp(ch,"down")) { if (j>p) w[temp[j]]=+1; else w[temp[j]]=-1; } } } } for (i=1;i<=12;i++) if (q[i]==up) { cout<<(char)(i+(int)'A'-1)<<" is the counterfeit coin and it is "; if (w[i]>0) cout<<"heavy."<<endl; else cout<<"light."<<endl; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator