在主要学习 Java 之后,我本学期刚开始学习 C,我被要求创建一个程序,允许用户输入字符串,然后打乱字符串中的字母。
#include <stdio.h> //Alows input/output operations
#include <stdlib.h> //Standard utility operations
int main(int argc, char *argv[]) //Main method
{
printf("------------------------\n");
printf("WELCOME TO THE SCRAMBLER\n");
printf("------------------------\n\n");
char userString[50]; //Declaring the user string
printf("Please input a String :> "); //Iforms the user to enter a string
scanf("%s", userString); //Allows the user to enter in a string
char targetLetter[2]; //Declaring the target letter
char replaceLetter[2]; //Declaring the replace letter
while(1)
{
}
}
这就是我目前所拥有的,我只需要有关如何实际打乱字符串的帮助/建议。用户应该能够随意加扰字符串,直到他们输入特定字符,然后程序终止。提前感谢您的帮助!