你这个B装的我给你100分。#include<stdio.h> //Include header file stdio.h
int main()//Main function main
{
char word[20];//define string word
char target;
char number;
int i=0;//define integer i
int j=0;
printf("\n------------------------\n");
printf("WELCOME TO THE SCRAMBLER\n");
printf("------------------------\n");
printf("Please enter your string:");
gets(word);//get strings
printf("\nWord is : %s\n",word);//out put word
printf("\nTarget :");
scanf("%c",&target);
while(getchar()!='\n');//make the program wait
while(j<100)//loop
{
if(target=='q')//check if there are target characters
{
printf("SCRAMBLED STRING IS :%s",word);
return 0;
}
else{
printf("Replace with:");
scanf("%c",&number);
while(getchar()!='\n');//make the program wait
printf("\nReplacing %c with %c\n",target,number);
i=0;
while(word[i]!='\0')//loop all the string
{
if(word[i]==target)//find the same string
{
word[i]=number;//replace target string to number
}
i++;//i=i+1
}
printf("Word is : %s\n",word);
printf("\nTarget :");
scanf("%c",&target);
while(getchar()!='\n');//make the program wait
}
j++;
}
return 0;
}
|