ZOJ 1146模拟题
题意是求七段数码管的显示,可将显示分为五个部分,垂直方向三个,水平方向两个;
最后再求五个部分的组合。。。。好麻烦呐,不过思路简单,可能模拟题都这样吧。。。。
View Code
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 #include<string.h> 5 6 void printv1(int s,int a) 7 { 8 int i; 9 printf(" "); 10 switch(a) 11 { 12 case 1: case 4: 13 for(i=0; i<s; i++) 14 printf(" "); 15 break; 16 case 2: case 3: case 5: case 6: case 7: case 8: case 9: case 0: 17 for(i = 0; i < s; i++) 18 printf("-"); 19 break; 20 } 21 printf(" "); 22 23 } 24 25 void printv2(int s,int a) 26 { 27 int i; 28 printf(" "); 29 switch(a) 30 { 31 case 1: case 7: case 0: 32 for(i = 0; i < s; i++) 33 printf(" "); 34 break; 35 case 2: case 3: case 4: case 5: case 6: case 8: case 9: 36 for(i = 0; i< s; i++) 37 printf("-"); 38 break; 39 } 40 printf(" "); 41 42 } 43 44 45 void printv3(int s, int a) 46 { 47 int i; 48 printf(" "); 49 switch(a) 50 { 51 case 1: case 4: case 7: 52 for(i=0; i<s; i++) 53 printf(" "); 54 break; 55 case 2: case 3: case 5: case 6: case 8: case 9: case 0: 56 for(i=0; i<s; i++) 57 printf("-"); 58 break; 59 } 60 61 printf(" "); 62 63 } 64 65 void printh1(int s,int a) 66 { 67 int i; 68 switch(a) 69 { 70 case 1: case 2: case 3: case 7: 71 printf(" "); 72 for(i = 0; i < s; i++) 73 printf(" "); 74 printf("|"); 75 break; 76 case 5: case 6: 77 printf("|"); 78 for(i=0; i<s; i++) 79 printf(" "); 80 printf(" "); 81 break; 82 case 4: case 8: case 9: case 0: 83 printf("|"); 84 for(i=0; i<s; i++) 85 printf(" "); 86 printf("|"); 87 break; 88 } 89 90 } 91 92 void printh2(int s,int a) 93 { 94 int i; 95 switch(a) 96 { 97 case 1: case 3: case 4: case 5: case 7: case 9: 98 printf(" "); 99 for(i=0; i<s; i++) 100 printf(" "); 101 printf("|"); 102 break; 103 case 2: 104 printf("|"); 105 for(i=0; i<s; i++) 106 printf(" "); 107 printf(" "); 108 break; 109 case 6: case 8: case 0: 110 printf("|"); 111 for(i=0; i<s; i++) 112 printf(" "); 113 printf("|"); 114 break; 115 116 } 117 118 } 119 120 int main() 121 { 122 int s,n,i,j,k,len; 123 char num[100]; 124 125 while(scanf("%d%s",&s,num) != EOF) 126 { 127 if( s==0 && num[0]=='0') break; 128 len = strlen(num); 129 for(i = 0; i < len; i++) 130 { 131 if(i != 0) 132 printf(" "); 133 printv1(s,num[i]-'0'); 134 } 135 printf("\n"); 136 137 for(i = 0; i < s; i++) 138 { 139 for(j = 0; j < len; j++) 140 { 141 if(j != 0) 142 printf(" "); 143 printh1(s,num[j]-'0'); 144 } 145 printf("\n"); 146 } 147 148 for(i=0; i<len; i++) 149 { 150 if(i != 0) 151 printf(" "); 152 printv2(s,num[i]-'0'); 153 } 154 printf("\n"); 155 156 for(i=0; i<s; i++) 157 { 158 for(j=0; j<len; j++) 159 { 160 if(j != 0) 161 printf(" "); 162 printh2(s,num[j]-'0'); 163 } 164 printf("\n"); 165 } 166 167 for(i=0; i<len; i++) 168 { 169 if(i != 0) 170 printf(" "); 171 printv3(s,num[i]-'0'); 172 } 173 printf("\n"); 174 175 printf("\n"); 176 177 } 178 179 return 0; 180 }
超过150行了。。。。第一次啊! 有木有!