有四个数字:1,2,3,4能组成多少个互不相同且无重复数字的三位数?各是多少? c语言题目:有1、2、3、4个数字,能组成多少个互不相同且无...
C++\u67091\u30015\u30019\u30018\u4e2a\u6570\u5b57\uff0c\u80fd\u7ec4\u6210\u591a\u5c11\u4e2a\u4e92\u4e0d\u76f8\u540c\u4e14\u65e0\u91cd\u590d\u6570\u5b57\u7684\u4e09\u4f4d\u6570\uff1f\u90fd\u662f\u591a\u5c11\uff08\u6700\u597d\u6700\u597d\u4e0d\u7528\u6570\u7ec4for\u5faa\u73af\u540e\u9762\u662f\u6ca1\u6709\u5206\u53f7\u7684\uff0c\u53ef\u4ee5\u4e0d\u7528\u8ba1\u7b97\uff0c\u76f4\u63a5\u8f93\u51fa\u5373\u53ef #include using namespace std;int main(){ int x,y,z,a; for (int x=1;x<=4;x++) { for (y=1;y<=4;y++) { for (z=1;z<=4;z++) { if(x!=y&&y!=z&&z!=x) cout<
\u767e\u4f4d\u6570\u67094\u79cd\u9009\u62e9\uff0c\u4e3a\u4e0e\u767e\u4f4d\u6570\u4e0d\u91cd\u590d\uff0c\u5341\u4f4d\u6570\u5c31\u53ea\u67093\u79cd\u9009\u62e9\u4e86\uff1b\u540c\u6837\u9053\u7406\uff0c\u4e2a\u4f4d\u6570\u5c31\u53ea\u67092\u79cd\u9009\u62e9\u3002\u6240\u4ee51\u30012\u30013\u30014\u7b494\u4e2a\u6570\u5b57\u80fd\u7ec4\u62104x3x2\u517124\u79cd\u4e92\u4e0d\u76f8\u7b49\u4e14\u6ca1\u6709\u91cd\u590d\u6570\u5b57\u76843\u4f4d\u6570\u3002\u6839\u636e\u4e0a\u8ff0\u539f\u7406\uff0c\u53ef\u7528\u4e00\u4e2a3\u5c42\u5d4c\u5957for\u5faa\u73af\u6765\u5b8c\u6210\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a
#include "stdio.h"int main(int argc,char *argv[]){
int i,j,k,t;printf("A total of %d no repeat number 3-digits, they are as follows:\n",4*3*2);
for(t=0,i=1;i<=4;i++)//\u767e\u4f4d\u6570\u5b57\u67094\u79cd\u9009\u62e9for(j=1;j<=4;j++)//\u5341\u4f4d\u6570\u5b57\u67093\u79cd\u9009\u62e9
if(j!=i)//\u9047\u5230\u5341\u4f4d\u6570\u5b57\u7b49\u4e8e\u767e\u4f4d\u6570\u5b57\u65f6\u8df3\u8fc7
for(k=1;k<=4;k++)//\u4e2a\u4f4d\u6570\u5b57\u53ea\u67092\u79cd\u9009\u62e9\u4e86
if(k!=i && k!=j)//\u4e2a\u4f4d\u6570\u5b57\u4e0e\u5341\u4f4d\u6216\u767e\u4f4d\u6570\u5b57\u76f8\u7b49\u65f6\u8df3\u8fc7
printf(++t%10 ? "%4d" : "%4d\n",i*100+j*10+k);//\u8f93\u51fa\u8be5\u4e09\u4f4d\u6570
if(t%10)printf("\n");
return 0;
}
\u6269\u5c55\u8d44\u6599
#include
main()
{
int i, j, k;
int m=0;
for(i=1;i<5;i++)
for(j=1;j<5;j++)
for(k=1;k<5;k++)
{
if(i!=j&&k!=j&&i!=k)
{
printf("%d%d%d\n",i,j,k);
m++;
}
}
printf("%d\n",m);
getch();
}
\u53c2\u8003\u8d44\u6599\uff1a\u767e\u5ea6\u767e\u79d1 for\u5faa\u73af
void main()
{
int x,a,b,c;
for(x=432;x>123;x--)
{
a=x/100;
b=x/10%10;
c=x%10;
x=100*a+10*b+c;
if(a!=b&&c!=b&&a!=c&&a<5&&b<5&&c<5&&a!=0&&b!=0&&c!=0)
{
printf("a=%d\tb=%d\tc=%d\t",a,b,c);
printf("the number is %d\n",x);
}
}
}
a=4 b=3 c=2 the number is 432
a=4 b=3 c=1 the number is 431
a=4 b=2 c=3 the number is 423
a=4 b=2 c=1 the number is 421
a=4 b=1 c=3 the number is 413
a=4 b=1 c=2 the number is 412
a=3 b=4 c=2 the number is 342
a=3 b=4 c=1 the number is 341
a=3 b=2 c=4 the number is 324
a=3 b=2 c=1 the number is 321
a=3 b=1 c=4 the number is 314
a=3 b=1 c=2 the number is 312
a=2 b=4 c=3 the number is 243
a=2 b=4 c=1 the number is 241
a=2 b=3 c=4 the number is 234
a=2 b=3 c=1 the number is 231
a=2 b=1 c=4 the number is 214
a=2 b=1 c=3 the number is 213
a=1 b=4 c=3 the number is 143
a=1 b=4 c=2 the number is 142
a=1 b=3 c=4 the number is 134
a=1 b=3 c=2 the number is 132
a=1 b=2 c=4 the number is 124
123
124
132
134
142
143
213
214
231
234
241
243
312
314
321
324
341
342
412
413
421
423
431
432
总共是5*5*5=125个
有1,2,3,4,5个数字,能组成125个互不相同且无重复数字的三位数
绛旓細4123,4132,4231,4213,4321,4312
绛旓細鐢1銆2銆3銆4鍥涗釜鏁板瓧锛缁勬垚涓変綅鏁鏈夛細4脳4脳4=64锛庢晠绛旀涓猴細64锛
绛旓細鐢1锛2锛3锛4杩4涓暟瀛楋紝鍙互缁勬垚24涓笉鍚岀殑鍥涗綅鏁.鍥涗釜鏁板瓧涓嶉噸澶嶇殑鏈夛細4脳3脳2脳1=24锛堜釜锛锛1鍋氬崈浣嶇殑鏈夛細3脳2脳1=6锛堜釜锛夛紝2鍋氬崈浣嶇殑鏈夛細3脳2脳1=6锛堜釜锛夛紝3鍋氬崈浣嶇殑鏈夛細3脳2脳1=6锛堜釜锛夛紝4鍋氬崈浣嶇殑鏈夛細3脳2脳1=6锛堜釜锛夛紝...
绛旓細绗竴浣鏈4涓閫夋嫨锛岀浜屼綅鏈3涓夋嫨锛岀涓変綅鏈2涓夋嫨锛屼竴鍏辫兘缁勬垚4x3x2锛24涓簰涓嶇浉鍚屼笖鏃犻噸澶鏁板瓧鐨涓浣嶆暟銆傚畠浠槸锛123/124/132/134/142/143/214/213/231/234/241/243/312/314/321/324/341/342/412/413/421/423/431/432銆
绛旓細浠1銆2銆3銆4杩欏洓涓暟瀛椾腑锛浠绘剰鎶藉嚭涓変釜鏁版潵杩涜鍏ㄦ帓鍒 A(4,3)=4脳3脳2=24 鎵浠ヨ繖鍥涗釜鏁拌兘澶熺粍鎴24涓簰涓嶇浉鍚屼笖娌℃湁閲嶅鏁板瓧鐨勪笁浣嶆暟銆
绛旓細鐧句綅鏁板瓧鏈4绉嶉夋硶锛屽崄浣鏁板瓧鏈3绉嶉夋硶锛屼釜浣鏁板瓧鏈2绉嶉夋硶銆傚叡鍙粍鎴 4脳3脳2=24涓笉鍚屼笁浣嶆暟銆傚垎鍒槸锛123,132,124,142,134,143,213,231,214,241,234,243,312,321,314,341,324,342,412,421,413,431,423,432銆
绛旓細4涓暟鐨勬帓鍒 = 4!=4*3*2*1=24 浠巒涓笉鍚屽厓绱犱腑鍙栧嚭m锛坢鈮锛変釜鍏冪礌鐨勬墍鏈夋帓鍒楃殑涓暟锛屽彨鍋氫粠n涓笉鍚屽厓绱犱腑鍙栧嚭m涓厓绱犵殑鎺掑垪鏁帮紝鐢ㄧ鍙 A锛坣,m锛夎〃绀恒傛帓鍒鏁帮細浠巒涓腑鍙杕涓帓涓涓嬶紝鏈塶(n-1)(n-2)...(n-m+1)绉嶏紝鍗硁!/(n-m)!缁勫悎鏁帮細浠巒涓腑鍙杕涓紝鐩稿綋浜庝笉鎺,灏辨槸...
绛旓細1.2.3.4杩鍥涗釜鏁缁勬垚鐨勪笁浣嶆暟鏈夛細123.124.132.134.142.143.231.234.241.243.213.214.312.314.321.324.341.342.412.413.421.423.431.432銆
绛旓細1鍦ㄥ崈浣嶆暟鏃剁殑缁勬垚锛1234銆1243銆1324銆1342銆1423銆1432锛屽叡6涓洓浣嶆暟銆傚悓鐞嗭紝褰2銆3銆4鍒嗗埆鍦ㄥ崈浣嶆暟鏃堕兘鍚勭粍鎴6涓洓浣嶆暟锛屼笖娌℃湁閲嶅锛屼竴鍏辨湁4x6=24涓洓浣嶆暟銆
绛旓細鐢1234鍥涗釜鏁板瓧锛屽彲浠ョ粍鎴愬灏戜釜涓や綅鏁拌鍒嗕袱绉嶆儏鍐碉細濡傛灉鏄笉鍏佽鏈夐噸澶嶆暟瀛楋紝閭e氨鏈 A锛4锛2锛=4脳3=12涓袱浣嶆暟锛涘鏋滃厑璁搁噸澶嶆暟瀛楋紝涔熷氨鏄鍗佷綅鏁板瓧鍙互鏈4绉嶆柟娉曪紝涓綅鏁板瓧涔熸槸4绉嶆柟娉曪紝鏍规嵁涔樻硶鍘熺悊涓鍏鏈 4脳4=16涓袱浣嶆暟銆傜浣犲ソ杩愶紒