2016-10-04 2 views
-4

예를 들어 "asd"가 있고 DAS, DSA, SAD에 무작위 화되기를 원합니다. 어떻게 코딩 할 수 있습니까? 몇 가지 해결책을 시도했지만 정말 작동하지 않았다. while 루프 내부C에서 문자열의 문자를 무작위로 배열

#include <stdio.h> 
#include <stdlib.h> 
#include <conio.h> 
#include <string.h> 


int main() 
{ 
    printf("type in the word\n"); 
    char haslo[128]; 
    scanf("%s", haslo); 
    char set[128]; 
    char hasloa[128]; 
    strcpy(set, haslo); 
    unsigned int Ind = 0; 
    srand(time(NULL) + rand()); 
    int len = strlen(set); 
    while(Ind < len) 
    { 
     hasloa[Ind++] = set[rand()%62]; 
    } 
    hasloa[len] = '\0'; 
    printf("%s", hasloa); 
    return 0; 
} 
+0

"렌"그리고 그 해결책이었다 하는가? – UnholySheep

+0

우리에게 "실제로 작동하지 않은 것"을 보여주십시오. –

+0

이들은 [순열] (https://en.wikipedia.org/wiki/Permutation)이라고합니다. 지금까지 뭐 해봤 어? – Kamiccolo

답변

-1

변경 62

관련 문제