當前位置:編程學習大全網 - 編程軟體 - 編程,在0123456789 10個數中輸入5個數隨機組合,將所有壹行五個數字的組合數全都列出來

編程,在0123456789 10個數中輸入5個數隨機組合,將所有壹行五個數字的組合數全都列出來

#include <stdio.h>

void main()

{

int n[5];

int t[5];

for( int i = 0; i < 5; i++ )

{

printf("請輸入第%d個數字:",i);

scanf("%d",n[i]); //如果要求每次輸入的數都不相同,請進行判斷,這個都會的。

}

for( t[0] = 0; t[0]<5; t[0]++ )

{

for( t[1] = 0; t[1]<5; t[1]++ )

{

if( t[1] == t[0] )continue;

for( t[2] = 0; t[2]<5; t[2]++ )

{

if( t[2] == t[1] || t[2] == t[0])continue;

for( t[3] = 0; t[3]<5; t[3]++ )

{

if( t[3] == t[2] || t[3] == t[1] || t[3] == t[0] )continue;

for( t[4] = 0; t[4]<5; t[4]++ )

{

if( t[4] == t[3] || t[4] == t[2] || t[4] == t[1] || t[4] == t[0] )continue;

printf("%d%d%d%d ",n[t[0]],n[t[1]],n[t[2]],n[t[3]],n[t[4]])

}

}

}

}

}

}

  • 上一篇:南昌勝利名樓小區周邊設施怎麽樣?
  • 下一篇:python中文亂碼是怎麽壹回事?
  • copyright 2024編程學習大全網