Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Kursovaya.cpp: главный файл проекта.
- #include "stdafx.h"
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <malloc.h>
- #include <string.h>
- using namespace std;
- using namespace System;
- using namespace System::IO;
- #define ENTER 13
- #define UP 72
- #define DOWN 80
- #define PAGEUP 33
- #define PAGEDOWN 34
- #define HOME 36
- #define END 35
- #define ESC 27
- struct z {
- char name[20];
- char vid[20];
- char mat[20];
- long quantity;
- long price;
- long cost;
- char data[11];
- };
- // char str[] = "Для продолжения работы нажмите клавишу...";
- int NC;
- char dan[10][58] = {
- "Alfavitniy spisok vseh zakupshikov ",
- "Spisok kompaniy, potrativshih bolee 100 000rub. ",
- "Kakaya kompaniya potratila menshe vsego deneg? ",
- "Kakie zakupshiki kupili odinakoviy tovar? ",
- "Kto proizvel zakupku ranshe ostalnyh? ",
- "Kto potratil bolshe vsego deneg? ",
- "Spisok zakupshikov, kotorie kupili \"Kaseti\" ",
- "Kakie zakupshiki kupili tovar iz odinakovogo materiala?",
- "Diagramma. Procentnoe sootnoshenie potrachennih deneg ",
- "Vihod "
- };
- char BlankLine[] = " "; //56 пробелов
- int menu(int);
- /*void first(struct z*);
- void list(struct z*);
- void minimum(struct z*);
- void samegood(struct z*);
- void data(struct z*);
- void maximum(struct z*);
- void ifkasset(struct z*);
- void samemat(struct z*);
- void diagram(struct z*);
- void press();*/
- int main()
- {
- int i, n;
- FILE *in;
- struct z *clients;
- Console::CursorVisible::set(false);
- Console::BufferHeight = Console::WindowHeight;
- Console::BufferWidth = Console::WindowWidth;
- if ((in = fopen("Dannie.txt", "r")) == NULL) {
- printf("\nFile Dannie.txt ne otrkit!");
- _getch();
- exit(1);
- }
- fscanf(in, "%d", &NC);
- clients = (struct z*)malloc(NC * sizeof(struct z));
- for (i = 0; i < NC; i++) {
- fscanf(in, "%s%s%s%ld%ld%ld%s",
- clients[i].name,
- clients[i].vid,
- clients[i].mat,
- &clients[i].quantity,
- &clients[i].price,
- &clients[i].cost,
- clients[i].data);
- }
- for (i = 0; i < NC; i++) {
- printf("\n%-20s %-20s %-20s %7ld %7ld %7ld &s");
- }
- _getch();
- while (1) {
- Console::ForegroundColor = System::ConsoleColor::Red;
- Console::BackgroundColor = System::ConsoleColor::Blue;
- Console::Clear();
- Console::ForegroundColor = System::ConsoleColor::Blue;
- Console::BackgroundColor = System::ConsoleColor::Red;
- Console::CursorLeft = 10;
- Console::CursorTop = 4;
- for (i = 0; i < 10; i++) {
- Console::CursorLeft = 10;
- Console::CursorTop = i + 5;
- printf(" %s ", dan[i]);
- }
- Console::CursorLeft = 10;
- Console::CursorTop = 12;
- printf(BlankLine);
- n = menu(10);
- /*switch (n){
- case 1: first(clients); break;
- case 2: list(clients); break;
- case 3: minimum(clients); break;
- case 4: samegood(clients); break;
- case 5: data(clients); break;
- case 6: maximum(clients); break;
- case 7: ifkasset(clients); break;
- case 8: samemat(clients); break;
- case 9: diagram(clients); break;
- case 10: exit(0);
- break;
- }*/
- }
- return 0;
- }
- int menu(int n) {
- int y1 = 0, y2 = n - 1;
- char c = 1;
- while (c != ESC) {
- switch (c) {
- case DOWN: y2 = y1; y1++; break;
- case UP: y2 = y1; y1--; break;
- case ENTER: return y1 + 1;
- break;
- }
- if (y1 > n - 1) {
- y2 = n - 1;
- y1 = 0;
- }
- if (y1 < 0) {
- y2 = 0;
- y1 = n - 1;
- }
- Console::ForegroundColor = System::ConsoleColor::White;
- Console::BackgroundColor = System::ConsoleColor::Black;
- Console::CursorLeft = 11;
- Console::CursorTop = y1 + 5;
- printf(dan[y1]);
- Console::ForegroundColor = System::ConsoleColor::Blue;
- Console::BackgroundColor = System::ConsoleColor::Red;
- Console::CursorLeft = 11;
- Console::CursorTop = y2 + 5;
- printf(dan[y2]);
- c = _getch();
- }
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement