#include<stdio.h> main() { int M,bigpreall,small,bigcomsma,all; int i; while(1) { bigpreall=1;small=1;bigcomsma=0; scanf("%d",&M); if(M==0) break; else { if(M==1) all=1; else if(M==2) all=2; else { for(i=1;i<=M-2;i++) { bigpreall= bigpreall+bigcomsma; bigcomsma=small; small= bigpreall; } all=bigpreall+small+bigcomsma; } } printf("%d\n",all); } } |
Double click to view unformatted code.