解题思路:
很简单看7根灯管的变化就行了;
参考代码:
#include<bits/stdc++.h> using namespace std; struct lig { int u, d, lu, ld, ru, rd, mid; }light[10] = { { 1,1,1,1,1,1,0 }, {0,0,0,0,1,1,0},{1,1,0,1,1,0,1},{1,1,0,0,1,1,1 } ,{0,0,1,0,1,1,1},{1,1,1,0,0,1,1} ,{1,1,1,1,0,1,1},{1,0,0,0,1,1,0},{1,1,1,1,1,1,1},{1,1,1,0,1,1,1} }; int fx(lig x, lig y) { int s = 0; if (x.u != y.u) s++; if (x.d != y.d) s++; if (x.lu != y.lu) s++; if (x.ld != y.ld) s++; if (x.ru != y.ru) s++; if (x.rd != y.rd) s++; if (x.mid != y.mid) s++; return s; } int main() { char a[200], b[200]; int n, sum = 0; cin >> n >> a >> b; for (int i = 0; i <= n; i++) { sum +=( fx(light[(a[i] - '0')], light[(b[i] - '0')])); } cout << sum; }
0.0分
6 人评分