C programming

Wednesday, February 4, 2009

#include void main() { FILE *fpin,*fpout; int b,i,j,k,d,c; char a[25]; fpin=freopen("c:\\work\\roman.in","r",stdin); fpout=freopen("c:\\work\\roman.out","w",stdout); while(scanf("%d%d",&d,&b)==2) { for(i=d;i<=b;i++) { j=0; c=i; if(c==0) { a[j]='0'; j++; } else { while(c!=0) { if(c/10>0) { for(k=0;k<(c/10);k++) { a[j]='X'; j++; } c=c-(10*j); //if(c==1) // c=0; } else if(c==9) { a[j]='I'; a[j+1]='X'; j=j+2; // c=c/5; //if(c==1) c=0; } else if(c>=5) { a[j]='V'; j++; for(k=0;k<(c-5);k++) { a[j]='I'; j++; } // j=j+2; // c=c/4; // if(c==1) c=0; } else if(c==4) { a[j]='I'; a[j+1]='V'; // a[j+2]='I'; j=j+2; // c=c/3; //if(c==1) c=0; } else if(c>=1) { for(k=0;k { a[j]='I'; // a[j+1]='I'; j=j+1; // c=c/2; // if(c==1) } c=0; } // else if(c==1) // { // a[j]='I'; // j++; // } } } printf("%d=",i); for(k=0;k { printf("%c",a[k]); } printf("\n"); } } }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP