Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static string Replace(string text, string st1, string st2)
- {
- int x, y;
- x = text.IndexOf(st1);
- y = text.IndexOf(st2);
- if (x > y)
- {
- text = text.Replace(st2, st1);
- }
- else
- text = text.Replace(st1, st2);
- return text;
- }
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- string word = Console.ReadLine();
- string word2 = Console.ReadLine();
- Console.WriteLine(Replace(text, word, word2));
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment