| ||||||||||
| 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 | |||||||||
Re:It's my programme with the explanation.In Reply To:It's my programme with the explanation. Posted by:fxzy at 2006-02-21 11:35:00 > #include <stdio.h>
> int guess[31][31];
> int get(int a,int b)
> {
> if(a<0||b<0) return 0; //a,b越界,则没猜到,即为0
> else return guess[a][b];
> }
> int main()
> {
> int G,L,i,j,cas=0;
> for(i=1;i<=30;i++)
> for(j=0;j<=30;j++)
> guess[i][j]=1+get(i-1,j-1)+get(i-1,j);//get(i-1,j-1)是猜大了,get(i-1,j)是猜小了,+1是猜对
> while(1)
> {
> scanf("%d%d",&G,&L);
> if(G==0&&L==0) return 0;
> printf("Case %d: %d\n",++cas,guess[G][L]);
> }
> }
int 的范围小了吧!
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator