Advertisement
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;
- using System.IO;
- namespace IT4
- {
- class PraceSeSoubory
- {
- public static void cteniZeSouboru()//načte celý soubor do stringu
- {
- //string cesta = "C:\\Users\\robert.hajda\\Documents\\text.txt";
- string cesta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\text.txt";
- string t = File.ReadAllText(cesta);
- Console.WriteLine(t);
- Console.ReadLine();
- }
- //****************************************************************************************Varianty:***************************************************************************************************************
- //program vrátí počet znaků ale bez mezer
- public static void cteniZeSouboru2()
- {
- string cesta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\jarek.txt";
- string t = File.ReadAllText(cesta);
- Console.WriteLine(t);
- int pocetMezer = 0;
- foreach (char z in t)
- if (z == ' ') pocetMezer++;
- int pocet = t.Length - pocetMezer;
- Console.WriteLine("počet znaků bez mezer: " + pocet);
- Console.ReadLine();
- }
- public static void uvod()
- {
- string cesta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\jarek.txt";
- string[] soubor = File.ReadAllLines(cesta);
- double soucet = 0;
- foreach (string radek in soubor)
- {
- Console.WriteLine(radek);
- soucet = soucet + double.Parse(radek.Substring(radek.IndexOf(' ')));
- }
- Console.WriteLine(soucet);
- Console.ReadLine();
- }
- public static void uvod33()
- {
- string cesta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\jarek.txt";
- double max = double.MinValue;
- string[] soubor = File.ReadAllLines(cesta);
- double soucet = 0;
- foreach (string radek in soubor)
- {
- Console.WriteLine(radek);
- double cislo = double.Parse(radek.Substring(radek.IndexOf(' ')));
- soucet = soucet + cislo;
- if (cislo == max) max = cislo;
- }
- Console.WriteLine(soucet);
- Console.WriteLine("maxim: ");
- foreach (string radek in soubor)
- {
- double cislo = double.Parse(radek.Substring(radek.IndexOf(' ')));
- if (cislo == max) Console.WriteLine(radek);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement