记一个生成罗马数字的代码
1 int f[15]={1,4,5,9,10,40,50,90,100,400,500,900,1000},num[10]; 2 int co[15][10]={{1},{1,1},{0,1},{1,0,1},{0,0,1},{0,0,1,1},{0,0,0,1},{0,0,1,0,1},{0,0,0,0,1},{0,0,0,0,1,1},{0,0,0,0,0,1},{0,0,0,0,1,0,1},{0,0,0,0,0,0,1}}; 3 char ss[10] = {'I','V','X','L','C','D','M'}; 4 void pre(int x) 5 { 6 int i,j; 7 for(i = 12 ; i >=0 ; i--) 8 { 9 if(x>=f[i]) 10 { 11 while(x>=f[i]) 12 { 13 x-=f[i]; 14 for(j = 0; j < 7 ; j++) 15 { 16 num[j]+=co[i][j]; 17 } 18 } 19 } 20 } 21 }