Advertisement
Guest User

123

a guest
Dec 8th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10.  
  11. namespace Storage
  12. {
  13.     struct Tovar
  14.     {
  15.         public string Name; //наименование
  16.         public double Price; //Стоимость
  17.         public string Sort; //Сорт
  18.         public int Amount; //Количество
  19.     }
  20.  
  21.    
  22.     public partial class Form1 : Form
  23.     {
  24.         Tovar[] MyStorage;
  25.         int Size; //Кол-во различных товаров различных видов
  26.         public Form1()
  27.         {
  28.             InitializeComponent();
  29.             string[] str; //массив строк
  30.                           //считывание данных из файла в массив строк
  31.             str = File.ReadAllLines(@"d:\storage.txt");
  32.             int n = str.Length; //определение количества элементов в массиве
  33.                                 //каждый вопрос в файле занимает 7 строк
  34.             Size = n / 4; //определение количества вопросов в файле
  35.             MyStorage = new Tovar[Size];
  36.             int m = 0;
  37.             //заполнение массива товаров
  38.             for (int j = 0; j < Size; j++)
  39.             {
  40.                 MyStorage[j].Name = str[m]; m++;
  41.                 MyStorage[j].Price = Convert.ToInt32(str[m]); m++;
  42.                 MyStorage[j].Sort = str[m]; m++;
  43.                 MyStorage[j].Amount = Convert.ToInt32(str[m]); m++;
  44.                 //определение максимального суммарного балла вопроса
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement