Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace Storage
- {
- struct Tovar
- {
- public string Name; //наименование
- public double Price; //Стоимость
- public string Sort; //Сорт
- public int Amount; //Количество
- }
- public partial class Form1 : Form
- {
- Tovar[] MyStorage;
- int Size; //Кол-во различных товаров различных видов
- public Form1()
- {
- InitializeComponent();
- string[] str; //массив строк
- //считывание данных из файла в массив строк
- str = File.ReadAllLines(@"d:\storage.txt");
- int n = str.Length; //определение количества элементов в массиве
- //каждый вопрос в файле занимает 7 строк
- Size = n / 4; //определение количества вопросов в файле
- MyStorage = new Tovar[Size];
- int m = 0;
- //заполнение массива товаров
- for (int j = 0; j < Size; j++)
- {
- MyStorage[j].Name = str[m]; m++;
- MyStorage[j].Price = Convert.ToInt32(str[m]); m++;
- MyStorage[j].Sort = str[m]; m++;
- MyStorage[j].Amount = Convert.ToInt32(str[m]); m++;
- //определение максимального суммарного балла вопроса
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement