Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- a)Zdefiniuj klasę odczytującą dane z pliku napisy.txt ( w pliku znajdują się liczby binarne). Na
- konsole wypisz największą liczbę w zapisie binarnym.
- b)Stwórz klasę Disparity , z publicznie dostępną tablicą ,z metodą publiczną , która zwraca różnicę
- wszystkich liczb , oraz metodę ,która wypisuje na ekran wszystkie liczby podzielne przez 10.
- */
- namespace zad1
- {
- class Program
- {
- static void Main(string[] args)
- {
- String path = @"C:\Users\mitura\Documents\Visual Studio
- 2005\Projects\zad1\zad1\text.txt";
- string line;
- long result = 0, max = 0;
- FileStream fs = new FileStream(path, FileMode.OpenOrCreate,
- FileAccess.ReadWrite);
- StreamReader sr = new StreamReader(fs);
- while ((line = sr.ReadLine()) != null)
- {
- Console.WriteLine(line);
- result = Convert.ToInt64(line, 2);
- //Console.WriteLine(result);
- if (result > max) max = result;
- }
- Console.WriteLine(max);
- Console.ReadKey();
- }
- }
- }
- */
- /* ZAD 2
- class Disparity {
- public int []tab;
- public void pokazPodzielnePrzez10() {
- Console.WriteLine("DZIESIETNE:");
- int size = tab.Length;
- for (int i = 0; i < size; i++) {
- int tmp = tab[i];
- if(tmp%10==0) Console.WriteLine(tmp);
- }
- }
- public void pokazRoznice() {
- Console.WriteLine("ROZNICE:");
- int size = tab.Length;
- for (int i = 0; i < size; i++){
- for (int j = 0; j < size; j++){
- int tmp1 = tab[i];
- int tmp2 = tab[j];
- if (tmp1 != tmp2) {
- if (tmp1 > tmp2) Console.WriteLine(tmp1 - tmp2);
- else Console.WriteLine(tmp2 - tmp1);
- }
- }
- }
- }
- };
- namespace zad1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Disparity dis = new Disparity();
- int[]tabTmp = new int[]{12,26,30,44,50};
- dis.tab = tabTmp;
- dis.pokazPodzielnePrzez10();
- dis.pokazRoznice();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment