Using System; using System. Io; namespace



Download 0,6 Mb.
bet2/2
Sana11.01.2022
Hajmi0,6 Mb.
#351582
1   2
Bog'liq
Text 1(1)

using System;
using System.IO;

namespace Text_2
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s,a=null;int i,n;
            Console.Write("Fayl nomi kiriting: ");
            s=Console.ReadLine();
            Console.Write("n=");
            n=int.Parse(Console.ReadLine());
            StreamWriter b=File.AppendText(@"d:\"+s);
            for (i=0;i            {
                a+=(char)('a'+i);b.WriteLine(a);
            }
            b.Close();
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 3. Fayl nomi va natural son berilgan . Yangi matnli fayl hosil qilinsin, uni ta satriga uzunligi ga teng bo’lib quyidagicha yozilsin: satriga dastlabki ta kata lotin harfi va o’ng tominiga “*” bilan to’ldirilsin. Masalan, uchun fayl satrlari quyidagicha bo’lishi kerak: “A***”, “AB**”, “ABC*”, “ABCD”

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_3
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s,a;int i,n;
            Console.Write("Fayl nomi kiriting: ");
            s=Console.ReadLine();
            Console.Write("n=");
            n=int.Parse(Console.ReadLine());
            StreamWriter b=File.AppendText(@"d:\"+s);
            for (i=0;i            {
                a=null;for (int j=0;jif (j<=i) a+=(char)('A'+j);
                else a+="*";b.WriteLine(a);
            }
            b.Close();
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 4. Matnli fayl berilgan. Undagi satrlar va simvollar sonini chiqarish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_4
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i,n=0;
            Console.Write("Fayl nomi kiriting: ");
            s=Console.ReadLine();
            string [] a=File.ReadAllLines(@"d:\"+s);
            for (i=0;i            Console.WriteLine("Satrlar soni: {0}\nBelgilar soni: {1}",a.Length,n);
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 5. satr va matnli fayl berilgan. Fayl oxiriga satrni qo’shish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_5
{
    class Program
    {
        public static void Main(string[] args)
        {
            string a,s;int i,n=0;
            Console.Write("Fayl nomi kiriting: ");
            a=Console.ReadLine();
            Console.Write("Satr kiriting: ");
            s=Console.ReadLine();
            File.AppendAllText(@"d:\"+a,s);
            Console.WriteLine(File.ReadAllText(@"d:\"+a));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 6. 2 ta matnli fayl berilgan. birinchi fayl oxiriga ikkinchi faylni qo’shish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_6
{
    class Program
    {
        public static void Main(string[] args)
        {
            string a,s;
            Console.Write("1-fayl nomini kiriting: ");
            a=Console.ReadLine();
            Console.Write("2-fayl nomini kiriting: ");
            s=Console.ReadLine();File.AppendAllText(@"d:\"+a,"\n");
            File.AppendAllLines(@"d:\"+a,File.ReadAllLines(@"d:\"+s));
            Console.WriteLine(File.ReadAllText(@"d:\"+a));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 7. satr va matnli fayl berilgan. Fayl boshiga satrni qo’shish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_7
{
    class Program
    {
        public static void Main(string[] args)
        {
            string a,s;
            Console.Write("Fayl nomini kiriting: ");
            a=Console.ReadLine();
            Console.Write("Satr kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+a);
            File.WriteAllText(@"d:\"+a,s+"\n");
            File.AppendAllLines(@"d:\"+a,b);
            Console.WriteLine(File.ReadAllText(@"d:\"+a));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 8. 2 ta matnli fayl berilgan. Birinchi fayl boshiga ikkinchi faylni qo’shish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_8
{
    class Program
    {
        public static void Main(string[] args)
        {
            string a,s;
            Console.Write("1-fayl nomini kiriting: ");
            a=Console.ReadLine();
            Console.Write("2-fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+a);
            File.WriteAllLines(@"d:\"+a,File.ReadAllLines(@"d:\"+s));
            File.AppendAllLines(@"d:\"+a,b);
            Console.WriteLine(File.ReadAllText(@"d:\"+a));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 9. natural son va matnli fayl berilgan. Faylning - nomerli satri oldidan bo’sh satr qo’shish dasturi tuzilsin. Agar bunday nomerli satr bo’lmasa fayl o’zgarishsiz qolsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_9
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i,j,k;
            Console.Write("Natural son kiriting: ");
            k=int.Parse(Console.ReadLine());
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            string [] a=new string[b.Length+1];
            if (b.Length>k) 
            {
                for (j=0,i=0;i<=b.Length;i++,j++) 
                {a[i]=b[j];if (i==k-1) {i++;a[i]=null;}}
            }
            File.WriteAllLines(@"d:\"+s,a);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 10. natural son va matnli fayl berilgan. Faylning - nomerli satrdan keyin bo’sh satr qo’shish dasturi tuzilsin. Agar bunday nomerli satr bo’lmasa fayl o’zgarishsiz qolsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_10
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i,j,k;
            Console.Write("Natural son kiriting: ");
            k=int.Parse(Console.ReadLine());
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            string [] a=new string[b.Length+1];
            if (b.Length>k) 
            {
                for (j=0,i=0;i<=b.Length;i++,j++) 
                {a[i]=b[j];if (i==k) {i++;a[i]=null;}}
                File.WriteAllLines(@"d:\"+s,a);
            }
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 11. Matnli fayl berilgan. Undagi barcha bo’sh satrlarni ikkilantirish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_11
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i;
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            for (i=0;i            {
                if (b[i]=="") b[i]="\n"+b[i];
            }
            File.WriteAllLines(@"d:\"+s,b);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 12. satr va matnli fayl berilgan. Undagi barcha bo’sh satrlarni o’rniga satrni yozish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_12
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s,S;int i;
            Console.Write("Fayl nomini kiriting: ");
            S=Console.ReadLine();
            Console.Write("Satr kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+S);
            Console.WriteLine(File.ReadAllText(@"d:\"+S));
            for (i=0;i            {
                if (b[i]=="") b[i]=s;
            }
            File.WriteAllLines(@"d:\"+S,b);
            Console.WriteLine(File.ReadAllText(@"d:\"+S));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 13. Bo’sh bo’lmagan matnli fayl berilgan. Undagi birinchi satrni o’chirish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_13
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i;
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            string [] a=new string[b.Length-1];
            for (i=1;i            File.WriteAllLines(@"d:\"+s,a);
            Console.WriteLine("Natija:\n"+File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 14. Bo’sh bo’lmagan matnli fayl berilgan. Undagi oxirgi satrni o’chirish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_14
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i;
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            string [] a=new string[b.Length-1];
            for (i=0;i            File.WriteAllLines(@"d:\"+s,a);
            Console.WriteLine("\nNatija:\n"+File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 15. natural son va matnli fayl berilgan. Undagi nomerli satrini o’chirish dasturi tuzilsin. Agar faylda nomerli satr bo’lmasa fayl o’zgarishsiz qolsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_15
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i,k,j=0;
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            Console.Write("Natural son kiriting: ");
            k=int.Parse(Console.ReadLine());
            string [] b=File.ReadAllLines(@"d:\"+s);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            if (k<=b.Length)
            {
               string [] a=new string[b.Length-1];
               for (i=0;iif (k!=i+1) {a[j]=b[i];j++;}
               File.WriteAllLines(@"d:\"+s,a);  
            }
            Console.WriteLine("\nNatija:\n"+File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 16. Matnli fayl berilgan. Undagi barcha bo’sh satrlarni o’chirish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_16
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s;int i,j=0;
            Console.Write("Fayl nomini kiriting: ");
            s=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            string [] a=new string[b.Length-1];
            for (i=0;iif (b[i]!="") {a[j]=b[i];j++;}
            File.WriteAllLines(@"d:\"+s,a);  
            Console.WriteLine("\nNatija:\n"+File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 17. 2 ta matnli fayl berilgan. Birinchi faylning har bir satr oxiridan ikkinchi faylning mos satrlarini qo’shish dasturi tuzilsin. Agar birinchi fayl satlari soni ikkinchisidan katta bo’lsa, qo;gan satrlari o’zgarishsiz qolsin.

Dasturning C# dagi ko’rinishi:

using System;
using System.IO;

namespace Text_17
{
    class Program
    {
        public static void Main(string[] args)
        {
            string s,S;int i;
            Console.Write("1-fayl nomini kiriting: ");
            s=Console.ReadLine();
            Console.Write("2-fayl nomini kiriting: ");
            S=Console.ReadLine();
            string [] b=File.ReadAllLines(@"d:\"+s);
            Console.WriteLine(File.ReadAllText(@"d:\"+s));
            string [] a=File.ReadAllLines(@"d:\"+S);
            Console.WriteLine(File.ReadAllText(@"d:\"+S));
            for (i=0;i            File.WriteAllLines(@"d:\"+s,b);  
            Console.WriteLine("\nNatija:\n"+File.ReadAllText(@"d:\"+s));
            Console.ReadKey(true);
        }
    }
}

Natija:


Text 18. natural son va matnli fayl berilgan. Faylning har bir satridan ta belgi o’chirilsin(agar satrning uzunligi kdan kichik bo’lsa satrning hammasi o’shirilsin).

Dasturning C# dagi ko’rinishi:

Natija:


Text 19. Matnli fayl berilgan. Undagi barcha katta haflrni kichigiga, kichigini esa kattasiga almashtirish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

Natija:

Text 20. Matnli fayl berilgan. Undagi barcha ketma-ket ketlgan probellarni bitta probelga almashtirish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

Natija:


Text 21. Matnli satrlar soni 3 tadan ko’p bo’lgan fayl berilgan. Undan oxirgi 3 ta satrini o’chirish dasuri tuzilsin.

Dasturning C# dagi ko’rinishi:

Natija:

Text 22. naural son va matnli satrlar soni tadan ko’p bo’lgan fayl berilgan. Undan oxirgi ta satrini o’chirish dasuri tuzilsin.

Dasturning C# dagi ko’rinishi:

Natija:


Text 23. naural son va matnli satrlar soni tadan ko’p bo’lgan fayl berilgan. dastlabki faylning oxirgi ta satrini o’shida aks ettirgan yangi matnli fayl yaatilsin.

Dasturning C# dagi ko’rinishi:

Natija:

Text 24. Matnli fayl berilgan. Agar abzastlar bir-biridan bir yoki bir nechta bo’sh satrlar bilan ajratilgan bo’lsa, matndagi abzastlar sonini toppish dasturi tuzilsin.

Dasturning C# dagi ko’rinishi:

Natija:


Text 25. naural son va matnli fayl berilgan. Fayldan nomerli abzasini o’chirilsin, o’chirilgandan oldingi va keyingi bo’sh satrlar o’chirilmasin. Agar berilgan nomerli abzast bo’lmasa, fayl o’zgarishsiz qoldirilsin.

Dasturning C# dagi ko’rinishi:

Natija:

Text 26. Matnli fayl berilgan. Agar matndagi har bir abzastning birinchi satri 5 ta probel bilan boshlansa, ularning sonini toppish dasturi tuzilsin. Abzastlar o’rtasidagi bo’sh satrlar o’qilmasin.

Dasturning C# dagi ko’rinishi:

Natija:


Text 27. naural son va matnli fayl berilgan. Fayldan nomerli abzastini o’chirish dasturi tuzilsin. Abzastlar o’rtasidagi bo’sh satrlar o’qilmasin va o’chirilmasin.Agar matnda berilgan nomerli abzast bo’lmasa matn o’zgarishsiz qoldirilsin.

Dasturning C# dagi ko’rinishi:



Natija:
Download 0,6 Mb.

Do'stlaringiz bilan baham:
1   2




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