using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks;
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { #region //групировка #endregion Program p=new Program(); string str=null; int a, b, c; float f = 90.63364f; str = f.ToString(); //перобразование флоат в стринг
a = b = c = 12; Console.WriteLine(a); //просто вывод Console.WriteLine(b); Console.WriteLine(c); Console.WriteLine(f); Console.WriteLine(str); Console.WriteLine(p); //вывод информации о обьекте Console.WriteLine("{0} : {1}",a,b); //вывод многих елементов(форматированный) Console.WriteLine("{0:#.###}",f); //вывод флоата с определённым количеством знаков после запятой Console.WriteLine("{0:C}",f); //вывод в валюте(с локализацией)
string str2 = "bla_bla_bla"; string str3 = null; str3 += str2; //сумирование двох строк Console.WriteLine(str3[0]); //вывод первого елемента строки string st = str2.Substring(3, 3); //создание подрядка Console.WriteLine(st); Console.WriteLine(str2.Length); //вывод длины строки
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ConsoleApplication12 {
class Program { static void Main(string[] args) {
Console.Write("Сколько студентов?"); int count; int.TryParse(Console.ReadLine(), out count); Stack<Student> potok = new Stack<Student>(); for (int i = 0; i < count; i++) { Student st=new Student(); st.init(); potok.Push(st); } foreach (var student in potok) { student.print(); } Console.ReadKey(); }
} }
Код
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ConsoleApplication12 { class Student { private string imya; private string familiya; private string otchectvo; private string gruppa; private int vozrast; private int[][] otsenki = new int[3][];
public void init() { zhyrnall(); Console.Write("Имя "); imya = Console.ReadLine(); Console.Write("Фамилия "); familiya = Console.ReadLine(); Console.Write("Отчество "); otchectvo = Console.ReadLine(); Console.Write("Группа "); gruppa = Console.ReadLine(); Console.Write("Возраст "); int.TryParse(Console.ReadLine(), out vozrast); while (true) { int count = yspevaemost(); if (count == 0) break; }
}
private void zhyrnall() { otsenki[0]=new int[5]; otsenki[1] = new int[5]; otsenki[2] = new int[5]; }
private int yspevaemost() { Console.WriteLine("програмирование - 1"); Console.WriteLine("администрирование - 2"); Console.WriteLine("дизайн - 3"); Console.WriteLine("выход - 4"); int a; int.TryParse(Console.ReadLine(), out a); if (a == 1 || a == 2 || a == 3) { for (int i = 0; i < 5; i++) { if (otsenki[a - 1] [i]== 0) { Console.Write("Введите оценку: "); int.TryParse(Console.ReadLine(), out otsenki[a-1][i]); return 1; } if (i+1==5) { Console.WriteLine("Журналл по данному предмету полон."); return 1; } }
} else if (a == 4) { return 0; } else { Console.WriteLine("error"); return 1; } return 0; }
public void print() { Console.WriteLine("{0} : {1} : {2} : {3} : {4}",imya,familiya,otchectvo,gruppa,vozrast); for (int i = 0; i < otsenki.Length; i++) { if (i == 0) Console.Write("програмирование -"); if (i == 1) Console.Write("администрирование - "); if (i == 2) Console.Write("дизайн - "); for (int j = 0; j < otsenki[i].Length; j++) {