有一个英文单词,譬如abcdefg,只知道其中有3个字母是大写,怎么能列出所有可能?
答案:2 悬赏:50 手机版
解决时间 2021-04-22 06:24
- 提问者网友:鐵馬踏冰河
- 2021-04-22 03:00
QQ给我吧,我不知道怎么用着代码
最佳答案
- 五星知识达人网友:低音帝王
- 2021-04-22 04:27
#include <stdio.h>
int main()
{
int i, j, n, k;
k = 0;
for ( i = 0; i <= 0x7F; ++i ) {
n = 0;
for ( j = 0; j < 7; ++j ) {
if ( ( 1 << j ) & i ) ++n;
}
if ( n == 3 ) {
printf( "NO.%2d: ", ++k );
for ( j = 0; j < 7; ++j ) {
putchar( ( 1 << j ) & i ? 'A' + j : 'a' + j );
}
putchar( '\n' );
}
}
}
运行结果:
NO. 1: ABCdefg
NO. 2: ABcDefg
NO. 3: AbCDefg
NO. 4: aBCDefg
NO. 5: ABcdEfg
NO. 6: AbCdEfg
NO. 7: aBCdEfg
NO. 8: AbcDEfg
NO. 9: aBcDEfg
NO.10: abCDEfg
NO.11: ABcdeFg
NO.12: AbCdeFg
NO.13: aBCdeFg
NO.14: AbcDeFg
NO.15: aBcDeFg
NO.16: abCDeFg
NO.17: AbcdEFg
NO.18: aBcdEFg
NO.19: abCdEFg
NO.20: abcDEFg
NO.21: ABcdefG
NO.22: AbCdefG
NO.23: aBCdefG
NO.24: AbcDefG
NO.25: aBcDefG
NO.26: abCDefG
NO.27: AbcdEfG
NO.28: aBcdEfG
NO.29: abCdEfG
NO.30: abcDEfG
NO.31: AbcdeFG
NO.32: aBcdeFG
NO.33: abCdeFG
NO.34: abcDeFG
NO.35: abcdEFG
QQ:1.1.7.3.2.0.1.9.8.6
int main()
{
int i, j, n, k;
k = 0;
for ( i = 0; i <= 0x7F; ++i ) {
n = 0;
for ( j = 0; j < 7; ++j ) {
if ( ( 1 << j ) & i ) ++n;
}
if ( n == 3 ) {
printf( "NO.%2d: ", ++k );
for ( j = 0; j < 7; ++j ) {
putchar( ( 1 << j ) & i ? 'A' + j : 'a' + j );
}
putchar( '\n' );
}
}
}
运行结果:
NO. 1: ABCdefg
NO. 2: ABcDefg
NO. 3: AbCDefg
NO. 4: aBCDefg
NO. 5: ABcdEfg
NO. 6: AbCdEfg
NO. 7: aBCdEfg
NO. 8: AbcDEfg
NO. 9: aBcDEfg
NO.10: abCDEfg
NO.11: ABcdeFg
NO.12: AbCdeFg
NO.13: aBCdeFg
NO.14: AbcDeFg
NO.15: aBcDeFg
NO.16: abCDeFg
NO.17: AbcdEFg
NO.18: aBcdEFg
NO.19: abCdEFg
NO.20: abcDEFg
NO.21: ABcdefG
NO.22: AbCdefG
NO.23: aBCdefG
NO.24: AbcDefG
NO.25: aBcDefG
NO.26: abCDefG
NO.27: AbcdEfG
NO.28: aBcdEfG
NO.29: abCdEfG
NO.30: abcDEfG
NO.31: AbcdeFG
NO.32: aBcdeFG
NO.33: abCdeFG
NO.34: abcDeFG
NO.35: abcdEFG
QQ:1.1.7.3.2.0.1.9.8.6
全部回答
- 1楼网友:低血压的长颈鹿
- 2021-04-22 04:33
一个一个罗列出来不就好了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯