Home > Back-end >  Bosses about editing characters garbled
Bosses about editing characters garbled

Time:10-28


For what will be garbled words???????
How to change??????
#include
#include
Int main ()
{
Char STR [41]={1}, con [5]={1};
Int a, b, c, x, flag=0;
gets(str);
Gets (con);

//delete
If (con [0]=='D')
{
for(a=0; STR [a]!='\ n'; +)
{
If (STR [a]==con [2])
{
For (x=0; xPrintf (" % c ", STR [x]).
For (x=(a + 1); STR [x]!='\ n'; X++)
Printf (" % c ", STR [x]).
break;
}
If (STR [a]=='. ')
{
Puts (" Not exist ");
break;
}
}
}
//insert
If (con [0]=='I')
{
For (a=40; a>=0; A -)
{
If (STR [a]==con [2])
{
For (x=0; xPrintf (" % c ", STR [x]).
Printf (" % c ", con [4]);
For (x=a; STR [x]!='\ n'; X++)
Printf (" % c ", STR [x]).
break;
}
If (STR [a]==STR [0])
{
Puts (" Not exist ");
break;
}

}
}
//replace
If (con [0]=='R')
{
for(a=0; STR [a]!='\ n'; +)
{
If (STR [a]==con [2])
{
STR [a]=con [4];
Flag=1;
}
If (STR [a]=='. ')
{if (flag==1)
{
For (x=0; STR [x]!='\ n'; X++)
{printf (" % c ", STR [x]). } break;
}
The else
{
Puts (" Not exist ");
break;
}
}
}
}
return 0;
}

CodePudding user response:

CHCP system (" 437 ");

CodePudding user response:

 # include 
#include

Int main ()
{
Char STR [41]={1}, con [5]={1};
Int a, b, c, x, flag=0;

gets(str);
Gets (con);

//delete
If (con [0]=='D')
{
//for (a=0; STR [a]!='\ n'; +)
for(a=0; STR [a]!='\ 0'; +)
{
If (STR [a]==con [2])
{
For (x=0; xPrintf (" % c ", STR [x]).
//for (x=(a + 1); STR [x]!='\ n'; X++)
For (x=(a + 1); STR [x]!='\ 0'; X++)
Printf (" % c ", STR [x]).
break;
}
If (STR [a]=='. ')
{
Puts (" Not exist ");
break;
}
}
}
//insert
If (con [0]=='I')
{
For (a=40; a>=0; A -)
{
If (STR [a]==con [2])
{
For (x=0; xPrintf (" % c ", STR [x]).
Printf (" % c ", con [4]);
//for (x=a; STR [x]!='\ n'; X++)
For (x=a; STR [x]!='\ 0'; X++)
Printf (" % c ", STR [x]).
break;
}
If (STR [a]==STR [0])
{
Puts (" Not exist ");
break;
}

}
}
//replace
If (con [0]=='R')
{
for(a=0; STR [a]!='\ n'; +)
{
If (STR [a]==con [2])
{
STR [a]=con [4];
Flag=1;
}
If (STR [a]=='. ')
{if (flag==1)
{
//for (x=0; STR [x]!='\ n'; X++)
For (x=0; STR [x]!='\ 0'; X++)
{
Printf (" % c ", STR [x]).
}
break;
}
The else
{
Puts (" Not exist ");
break;
}
}
}
}
return 0;
}

For your reference ~

The code is the cause of an array. Gets function receives input string, won't add to the cache '\ n' (STR), so in cycle judgment '\ n' is not going to stop, so lead to cross-border,

  • Related