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


Dasturning C# dagi ko’rinishi



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

Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_24
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',','};double b,c=0;
int i,j,n=1;bool l=false,k=false;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
Console.Write("Yaratiladigan fayl nomini kiriting: ");
s1=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
b=Convert.ToDouble(a[0]);
if (i!=0) 
{
if (c>b|(c==b&n!=1)) {if (l){l=false;File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}n++;k=true;}
if (cif (k){k=false;File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}n++;l=true;}
}
for (j=0;j{
b=Convert.ToDouble(a[j]);c=Convert.ToDouble(a[j+1]);
if (cif (l){l=false;File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}n++;k=true;}
if (c>b|(c==b&l)) {if (k){k=false;File.AppendAllText(@"d:\"+s1,n.ToString()+" ");n=1;}n++;l=true;}
}
if (i==h.Length)File.AppendAllText(@"d:\"+s1,n.ToString()+" ");
}
Console.ReadKey(true);
}
}
}
Natija:
File 25. Butun sonlar fayli berilgan. Undagi barcha elementlarini ularning kvadratiga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_25
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};int i,j,n=1;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
File.WriteAllText(@"d:\"+s,"");
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=0;j{
n=Convert.ToInt32(a[j]);
File.AppendAllText(@"d:\"+s,(n*n).ToString()+" ");
}
string [] b={"\n"};
File.AppendAllLines(@"d:\"+s,b);
}
Console.ReadKey(true);
}
}
}
Natija:
File 26. Butun sonlar fayli berilgan. Undagi eng kichik va eng kata elementlar o’rnini almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_25
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',','};int i,j,n=1,min=0,max=0;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
File.WriteAllText(@"d:\"+s,"");
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=0;j{
n=Convert.ToInt32(a[j]);
if ((i==0&j==0)|min>n) min=n;
if ((i==0&j==0)|max}
}
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=0;j{
n=Convert.ToInt32(a[j]);
if (min==n) n=max;else if (max==n) n=min;
File.AppendAllText(@"d:\"+s,n.ToString()+" ");
}
string [] b={"\n"};
File.AppendAllLines(@"d:\"+s,b);
}
Console.ReadKey(true);
}
}
}
Natija:
File 27. elementli butun sonlar fayli berilgan ( undagi elementlar soni). Uning elementlari o’rnini quyidagicha almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_27
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',','};int j;
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 (j=0;j{
File.AppendAllText(@"d:\"+s,a[j]+" "+a[a.Length-1-j]+" ");
}
if (j%2==1) File.AppendAllText(@"d:\"+s,a[j/2]+" ");
Console.ReadKey(true);
}
}
}
Natija:
File 28. Haqiqiy sonlar fayli berilgan. Fayldagi birinchi va oxirgi elementdan tashqari hamma elementni uning barcha elementlari o’rta arifmetigiga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_28
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',';'};int i,j,n=0;double S=0;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
string [] h=File.ReadAllLines(@"d:\"+s);
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=0;jToDouble(a[j]);
n+=a.Length;
}
S=S/n;
for (i=0;i{
string [] a=h[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=0;jif (!(i==0&j==0)&!(i==h.Length-1&j==a.Length-1))a[j]=S.ToString();
h[i]=string.Join(" ",a);
}
File.WriteAllLines(@"d:\"+s,h);
Console.ReadKey(true);
}
}
}
Natija:
File 29. Haqiqiy sonlar fayli berilgan. Fayldagi birinchi va oxirgi elementdan tashqari hamma elementni uning barcha elementlari o’rta arifmetigiga almashtirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_29
{
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);
if (a.Length>50) s1=String.Join(" ",a,(a.Length-50+1)/2,49);
File.WriteAllText(@"d:\"+s,s1);
Console.ReadKey(true);
}
}
}
File 30. Elementlari miqdori juft bo’lgan butun sonlar fayli berilgan. Berilgan fayl elementlaridan ikkinchi yarmini o’chirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi;
using System;
using System.IO;

namespace File_30
{
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);
s1=String.Join(" ",a,0,(a.Length+1)/2);
File.WriteAllText(@"d:\"+s,s1);
Console.ReadKey(true);
}
}
}
File 31. Elementlari miqdori 50 dan oshiq bo’lgan butun sonlar fayli berilgan. Berilgan fayl elementlarini 50 tagacha kamaytiring, dastlabki elementlarini o’chirib.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_31
{
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);
if (a.Length>50) s1=String.Join(" ",a,a.Length-49,49);
File.WriteAllText(@"d:\"+s,s1);
Console.ReadKey(true);
}
}
}
File 32. Elementlari juft bo’lgan butun sonlar fayli berilgan. Fayldan birinchi yarmida joylashgan elementlarini o’chirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_31
{
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);
s1=String.Join(" ",a,((a.Length+1)/2),a.Length/2);
File.WriteAllText(@"d:\"+s,s1);
Console.ReadKey(true);
}
}
}
File 33. Butun sonlar fayli berilgan. Undan barcha juft nomerli elementlarini o’chirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_33
{
class Program
{
public static void Main(string[] args)
{
string s;char [] m={' ',';'};int i,j,n=0;
Console.Write("Mavjud fayl nomini kiriting: ");
s=Console.ReadLine();
string [] b=File.ReadAllLines(@"d:\"+s);
File.WriteAllText(@"d:\"+s,"");
for (i=0;i{
string [] a=b[i].Split(m,StringSplitOptions.RemoveEmptyEntries);
for (j=1;jAppendAllText(@"d:\"+s,a[j]+" "); 
if (a.Length%2==1) n=0;
else n=1;
}
Console.ReadKey(true);
}
}
}
File 34. Butun sonlar fayli berilgan. Undan barcha manfiy sonlarni o’chirish dasturi tuzilsin.
Dasturning C# dagi ko’rinishi:
using System;
using System.IO;

namespace File_34
{
class Program
{
public static void Main(string[] args)
{
string s,s1;char [] m={' ',';'};int j;
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);

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