目录
题目描述
本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
小蓝要用七段码数码管来表示一种特殊的文字。

上图给出了七段码数码管的一个图示,数码管中一共有 77 段可以发光的二 极管,分别标记为 a,b,c,d,e,f,g。
小蓝要选择一部分二极管(至少要有一个)发光来表达字符。在设计字符 的表达时,要求所有发光的二极管是连成一片的。
例如:b 发光,其他二极管不发光可以用来表达一种字符。
例如 c 发光,其他二极管不发光可以用来表达一种字符。这种方案与上 一行的方案可以用来表示不同的字符,尽管看上去比较相似。
例如:a,b,c,d,e 发光,f,g 不发光可以用来表达一种字符。
例如:b,f 发光,其他二极管不发光则不能用来表达一种字符,因为发光 的二极管没有连成一片。
请问,小蓝可以用七段码数码管表达多少种不同的字符?
运行限制
- 最大运行时间:1s
- 最大运行内存: 128M
原题链接
七段码https://www.lanqiao.cn/problems/595/learning/?page=1&first_category_id=1&problem_id=595
代码思路
java
public class Main{
public static void main(String[] args) {
int sum = 0;
for (int a = 0; a < 2; a++) {
for (int b = 0; b < 2; b++) {
for (int c = 0; c < 2; c++) {
for (int d = 0; d < 2; d++) {
for (int e = 0; e < 2; e++) {
for (int f = 0; f < 2; f++) {
for (int g = 0; g < 2; g++) {
if (a + b + c + d + e + f + g == 1) {
sum++;
continue;
}
if (a + b + c + d + e + f + g == 0) {
continue;
}
if (a == 1 && b == 0 && f == 0) {
continue;
}
if (b == 1 && a == 0 && g == 0 && c == 0) {
continue;
}
if (c == 1 && d == 0 && g == 0 && b == 0) {
continue;
}
if (d == 1 && c == 0 && e == 0) {
continue;
}
if (e == 1 && d == 0 && g == 0 && f == 0) {
continue;
}
if (f == 1 && a == 0 && g == 0 && e == 0) {
continue;
}
if (g == 1 && f == 0 && b == 0 && e == 0 && c == 0) {
continue;
}
if (a + b + c + d + e + f + g != 2) {
if (a == 1 && b == 1 && f == 0 && g == 0 && c == 0) {
continue;
}
if (a == 1 && f == 1 && b == 0 && g == 0 && e == 0) {
continue;
}
if (b == 1 && c == 1 && a == 0 && g == 0 && d == 0) {
continue;
}
}
sum++;
}
}
}
}
}
}
}
System.out.println(sum);
}
}