Using System. Io; namespace File 1 { class Program { public



Download 64,29 Kb.
bet6/6
Sana03.04.2022
Hajmi64,29 Kb.
#526700
1   2   3   4   5   6
Bog'liq
File 1

using System;
using System.IO;

namespace File_37
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',';'};
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s);
s1=b.ReadToEnd();b.Close();
string [] a=s1.Split(m,StringSplitOptions.RemoveEmptyEntries);
for (int i=a.Length-1;i>=0;i--) 
File.AppendAllText(@"d:\"+s," "+a[i]+" ");
Console.ReadKey(true);
}
}
}
File 38. Butun sonlar fayli berilgan. Uning juft nomerli elementlarini faylga qayta yozish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_38
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',';'};
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s);
s1=b.ReadToEnd();b.Close();
string [] a=s1.Split(m,StringSplitOptions.RemoveEmptyEntries);
for (int i=0;iFile.AppendAllText(@"d:\"+s," "+a[i]+" ");
Console.ReadKey(true);
}
}
}
File 39. Butun sonlar fayli berilgan. Uning barcha 5-10 diapozonga tegishli bo’lgan elementlarini qayta yozish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_39
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',';'};int i,n;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s);
s1=b.ReadToEnd();b.Close();
string [] a=s1.Split(m,StringSplitOptions.RemoveEmptyEntries);
for (i=0;i{
n=Convert.ToInt32(a[i]);
if (n>=5&n<=10) File.AppendAllText(@"d:\"+s," "+a[i]+" ");
}
Console.ReadKey(true);
}
}
}
File 40. Butun sonlar fayli berilgan. Undagi har bir juft nomerli elementni 2 ta nolga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_40
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',';'};int i,n;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s);
s1=b.ReadToEnd();b.Close();
File.WriteAllText(@"d:\"+s,"");
string [] a=s1.Split(m,StringSplitOptions.RemoveEmptyEntries);
for (i=0;i{
if (i%2==0) File.AppendAllText(@"d:\"+s,"0 0 ");
else File.AppendAllText(@"d:\"+s,a[i]+" ");
}
Console.ReadKey(true);
}
}
}
File 41. Butun sonlar fayli berilgan. Undagi har bir musbat elementni 3 ta nolga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_41
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',';'};int i,n;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s);
s1=b.ReadToEnd();b.Close();
File.WriteAllText(@"d:\"+s,"");
string [] a=s1.Split(m,StringSplitOptions.RemoveEmptyEntries);
for (i=0;i{
n=Convert.ToInt32(a[i]);
if (n>0) File.AppendAllText(@"d:\"+s,"0 0 0 ");
else File.AppendAllText(@"d:\"+s,a[i]+" ");
}
Console.ReadKey(true);
}
}
}
File 42. Ixtiyoriy tipli 2 ta fayl berilgan. Fayllar ichidagi ma’lumotlarni almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_42
{
class Program
{
public static void Main(string[] args)
{
string s,s1,s2,S;
Console.Write("1-fayl nomini kiriting: ");
s1=Console.ReadLine();
Console.Write("2-fayl nomini kiriting: ");
s2=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s1);
s=b.ReadToEnd();b.Close();
StreamReader a=File.OpenText(@"d:\"+s2);
S=a.ReadToEnd();a.Close();
File.WriteAllText(@"d:\"+s1,S);File.WriteAllText(@"d:\"+s2,s);
Console.ReadKey(true);
}
}
}
File 43. Ixtiyoriy tipli 2 ta fayl berilgan. Fayllar ichidagi ma’lumotlarni almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_43
{
class Program
{
public static void Main(string[] args)
{
string s,s1;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
Console.Write("Yangi fayl nomini kiriting: ");
s1=Console.ReadLine();
File.Copy(@"d:\"+s,@"d:\"+s1);
Console.ReadKey(true);
}
}
}
File 44. 3 ta bir xil tipli, lekin har xil razmerli fayllar berilgan. Uzunligi eng katta bo’lga faylni uzunligi eng kichik bo’lgan faylga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_44
{
class Program
{
public static void Main(string[] args)
{
string s1,s2,s3,d,f,h;
Console.Write("1-fayl nomini kiriting: ");
s1=Console.ReadLine();
Console.Write("2-fayl nomini kiriting: ");
s2=Console.ReadLine();
Console.Write("2-fayl nomini kiriting: ");
s3=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s1);
d=b.ReadToEnd();b.Close();
StreamReader a=File.OpenText(@"d:\"+s2);
f=a.ReadToEnd();a.Close();
StreamReader c=File.OpenText(@"d:\"+s1);
h=c.ReadToEnd();c.Close();
if (d.Length>f.Length)
{
if (f.Length>h.Length) File.WriteAllText(@"d:\"+s1,h);
else if (d.Length>h.Length) File.WriteAllText(@"d:\"+s1,f);
else File.WriteAllText(@"d:\"+s3,f);
}
else 
{
if (d.Length>h.Length)File.WriteAllText(@"d:\"+s2,h);
else if (f.Length>h.Length)File.WriteAllText(@"d:\"+s2,d);
else File.WriteAllText(@"d:\"+s3,d);
}
Console.ReadKey(true);
}
}
}
File 45. 3 ta bir xil tipli, lekin har xil razmerli fayllar berilgan. Uzunligi eng kichik bo’lga faylni uzunligi eng katta bo’lgan faylga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_45
{
class Program
{
public static void Main(string[] args)
{
string s1,s2,s3,d,f,h;
Console.Write("1-fayl nomini kiriting: ");
s1=Console.ReadLine();
Console.Write("2-fayl nomini kiriting: ");
s2=Console.ReadLine();
Console.Write("2-fayl nomini kiriting: ");
s3=Console.ReadLine();
StreamReader b=File.OpenText(@"d:\"+s1);
d=b.ReadToEnd();b.Close();
StreamReader a=File.OpenText(@"d:\"+s2);
f=a.ReadToEnd();a.Close();
StreamReader c=File.OpenText(@"d:\"+s1);
h=c.ReadToEnd();c.Close();
if (d.Length>f.Length)
{
if (f.Length>h.Length) File.WriteAllText(@"d:\"+s3,d);
else if (d.Length>h.Length) File.WriteAllText(@"d:\"+s2,d);
else File.WriteAllText(@"d:\"+s2,h);
}
else 
{
if (d.Length>h.Length)File.WriteAllText(@"d:\"+s3,f);
else if (f.Length>h.Length)File.WriteAllText(@"d:\"+s1,f);
else File.WriteAllText(@"d:\"+s1,h);
}
Console.ReadKey(true);
}
}
}
File 46. 3 ta bir xil tipli, lekin har xil razmerli fayllar berilgan. Uzunligi eng kichik bo’lga faylni uzunligi eng katta bo’lgan faylga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
Download 64,29 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish