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 |
刚学c语言,算法已经写好,谁能帮我完成输入和输出?#include "Stdio.h" main() {int k=0,i; long n1[3],n2[3],s1[23]={1,3,8}; long kk,tmp,s2[22]={2,5}; for(k=2;k<22;k++) {s1[k+1]=3*s1[k]-s1[k-1]; s2[k]=3*s2[k-1]-s2[k-2]; } printf("\nPlease input Three group numbers: "); for(i=0;i<3;i++) {scanf("%ld %ld",&n1[i],&n2[i]); if(n1[i]>n2[i]) { tmp=n1[i]; n1[i]=n2[i]; n2[i]=tmp; } } for(i=0;i<3;i++) { kk=n1[i]; for(k=0;k<23;k++) if(kk>=s1[k]&&kk<=s1[k+1]) break; if(k==23) {printf("Input errow!\n"); continue;} kk=kk-s1[k]; if(k>0) tmp=s2[k-1]; else tmp=1; while(k) { if (kk>=s1[k-1]+s2[k-1]) {kk-=s1[k-1]+s2[k-1]; if (k==1) tmp+=1+s1[k-1]; else tmp+=s2[k-2]+s1[k-1]; if(kk==0)break; k--;} else if(kk>=s1[k-1]) {kk-=s1[k-1]; if (k==1) tmp+=1; else tmp+=s2[k-2]; if(kk==0)break; k--;} else k--; } if(kk==0&&n2[i]-n1[i]==tmp) printf("shu\n"); else printf("win\n"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator