using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
Console.Write("filename = ");
string filename = Console.ReadLine();
if (File.Exists(filename))
{
FileStream fp = new FileStream(filename, FileMode.Open);
StreamReader reader = new StreamReader(fp);
Console.Write("masukan kata yg ingin diganti : ");
string n = (Console.ReadLine());
Console.Write("masukan kata yg ingin menggantikan : ");
string m = (Console.ReadLine());
string data;
while ((data = reader.ReadLine()) != null)
{
string[] kata = data.Split(' ');
int u = kata.Length;
for (int i = 0; i <= u - 1; i++)
{
int r = (kata[i].IndexOf(n));
if (r >= 0)
{
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.Write("ingin mengganti kata? (y/q)");
string l = (Console.ReadLine());
Console.WriteLine();
if (l == "y")
{
kata[i] = m;
for (int z = 0; z <= i; z++)
{
Console.Write("{0} ", kata[z]);
System.Threading.Thread.Sleep(100);
}
}
else
{
for (int j = 0; j <= u-1; j++)
{
Console.Write("{0} ", kata[j]);
System.Threading.Thread.Sleep(100);
}
u = kata.Length - kata.Length;
}
}
else
{
Console.Write(" {0}", kata[i]);
System.Threading.Thread.Sleep(100);
}
}
}
Console.WriteLine();
reader.Close();
fp.Close();
}
else
Console.WriteLine("file is not found!");
Console.WriteLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
Console.Write("filename = ");
string filename = Console.ReadLine();
if (File.Exists(filename))
{
FileStream fp = new FileStream(filename, FileMode.Open);
StreamReader reader = new StreamReader(fp);
Console.Write("masukan kata yg ingin diganti : ");
string n = (Console.ReadLine());
Console.Write("masukan kata yg ingin menggantikan : ");
string m = (Console.ReadLine());
string data;
while ((data = reader.ReadLine()) != null)
{
string[] kata = data.Split(' ');
int u = kata.Length;
for (int i = 0; i <= u - 1; i++)
{
int r = (kata[i].IndexOf(n));
if (r >= 0)
{
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.Write("ingin mengganti kata? (y/q)");
string l = (Console.ReadLine());
Console.WriteLine();
if (l == "y")
{
kata[i] = m;
for (int z = 0; z <= i; z++)
{
Console.Write("{0} ", kata[z]);
System.Threading.Thread.Sleep(100);
}
}
else
{
for (int j = 0; j <= u-1; j++)
{
Console.Write("{0} ", kata[j]);
System.Threading.Thread.Sleep(100);
}
u = kata.Length - kata.Length;
}
}
else
{
Console.Write(" {0}", kata[i]);
System.Threading.Thread.Sleep(100);
}
}
}
Console.WriteLine();
reader.Close();
fp.Close();
}
else
Console.WriteLine("file is not found!");
Console.WriteLine();
}
}
}
No comments:
Post a Comment