Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.96 KB | None | 0 0
  1. // Kursovaya.cpp: главный файл проекта.
  2.  
  3. #include "stdafx.h"
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <malloc.h>
  8. #include <string.h>
  9.  
  10. using namespace std;
  11. using namespace System;
  12. using namespace System::IO;
  13.  
  14. #define ENTER 13
  15. #define UP 72
  16. #define DOWN 80
  17. #define PAGEUP 33
  18. #define PAGEDOWN 34
  19. #define HOME 36
  20. #define END 35
  21. #define ESC 27
  22.  
  23. struct z {
  24.     char name[20];
  25.     char vid[20];
  26.     char mat[20];
  27.     long quantity;
  28.     long price;
  29.     long cost;
  30.     char data[11];
  31. };
  32.  
  33. // char str[] = "Для продолжения работы нажмите клавишу...";
  34. int NC;
  35. char dan[10][58] = {
  36.     "Alfavitniy spisok vseh zakupshikov                     ",
  37.     "Spisok kompaniy, potrativshih bolee 100 000rub.        ",
  38.     "Kakaya kompaniya potratila menshe vsego deneg?         ",
  39.     "Kakie zakupshiki kupili odinakoviy tovar?              ",
  40.     "Kto proizvel zakupku ranshe ostalnyh?                  ",
  41.     "Kto potratil bolshe vsego deneg?                       ",
  42.     "Spisok zakupshikov, kotorie kupili \"Kaseti\"          ",
  43.     "Kakie zakupshiki kupili tovar iz odinakovogo materiala?",
  44.     "Diagramma. Procentnoe sootnoshenie potrachennih deneg  ",
  45.     "Vihod                                                  "
  46. };
  47.  
  48. char BlankLine[] = "                                                        "; //56 пробелов
  49.  
  50. int menu(int);
  51. /*void first(struct z*);
  52. void list(struct z*);
  53. void minimum(struct z*);
  54. void samegood(struct z*);
  55. void data(struct z*);
  56. void maximum(struct z*);
  57. void ifkasset(struct z*);
  58. void samemat(struct z*);
  59. void diagram(struct z*);
  60. void press();*/
  61.  
  62. int main()
  63. {
  64.     int i, n;
  65.     FILE *in;
  66.     struct z *clients;
  67.  
  68.     Console::CursorVisible::set(false);
  69.     Console::BufferHeight = Console::WindowHeight;
  70.     Console::BufferWidth = Console::WindowWidth;
  71.  
  72.     if ((in = fopen("Dannie.txt", "r")) == NULL) {
  73.         printf("\nFile Dannie.txt ne otrkit!");
  74.         _getch();
  75.         exit(1);
  76.     }
  77.     fscanf(in, "%d", &NC);
  78.     clients = (struct z*)malloc(NC * sizeof(struct z));
  79.     for (i = 0; i < NC; i++) {
  80.         fscanf(in, "%s%s%s%ld%ld%ld%s",
  81.             clients[i].name,
  82.             clients[i].vid,
  83.             clients[i].mat,
  84.             &clients[i].quantity,
  85.             &clients[i].price,
  86.             &clients[i].cost,
  87.             clients[i].data);
  88.     }
  89.     for (i = 0; i < NC; i++) {
  90.         printf("\n%-20s %-20s %-20s %7ld %7ld %7ld &s");
  91.     }
  92.     _getch();
  93.  
  94.     while (1) {
  95.  
  96.         Console::ForegroundColor = System::ConsoleColor::Red;
  97.         Console::BackgroundColor = System::ConsoleColor::Blue;
  98.         Console::Clear();
  99.         Console::ForegroundColor = System::ConsoleColor::Blue;
  100.         Console::BackgroundColor = System::ConsoleColor::Red;
  101.         Console::CursorLeft = 10;
  102.         Console::CursorTop = 4;
  103.  
  104.         for (i = 0; i < 10; i++) {
  105.             Console::CursorLeft = 10;
  106.             Console::CursorTop = i + 5;
  107.             printf(" %s ", dan[i]);
  108.         }
  109.  
  110.         Console::CursorLeft = 10;
  111.         Console::CursorTop = 12;
  112.         printf(BlankLine);
  113.  
  114.         n = menu(10);
  115.         /*switch (n){
  116.         case 1: first(clients); break;
  117.         case 2: list(clients); break;
  118.         case 3: minimum(clients); break;
  119.         case 4: samegood(clients); break;
  120.         case 5: data(clients); break;
  121.         case 6: maximum(clients); break;
  122.         case 7: ifkasset(clients); break;
  123.         case 8: samemat(clients); break;
  124.         case 9: diagram(clients); break;
  125.         case 10: exit(0);
  126.         break;
  127.         }*/
  128.     }
  129.     return 0;
  130. }
  131.  
  132. int menu(int n) {
  133.     int y1 = 0, y2 = n - 1;
  134.     char c = 1;
  135.     while (c != ESC) {
  136.  
  137.         switch (c) {
  138.         case DOWN: y2 = y1; y1++; break;
  139.         case UP: y2 = y1; y1--; break;
  140.         case ENTER: return y1 + 1;
  141.             break;
  142.         }
  143.         if (y1 > n - 1) {
  144.             y2 = n - 1;
  145.             y1 = 0;
  146.         }
  147.         if (y1 < 0) {
  148.             y2 = 0;
  149.             y1 = n - 1;
  150.         }
  151.  
  152.         Console::ForegroundColor = System::ConsoleColor::White;
  153.         Console::BackgroundColor = System::ConsoleColor::Black;
  154.         Console::CursorLeft = 11;
  155.         Console::CursorTop = y1 + 5;
  156.         printf(dan[y1]);
  157.         Console::ForegroundColor = System::ConsoleColor::Blue;
  158.         Console::BackgroundColor = System::ConsoleColor::Red;
  159.         Console::CursorLeft = 11;
  160.         Console::CursorTop = y2 + 5;
  161.         printf(dan[y2]);
  162.         c = _getch();
  163.     }
  164.     exit(0);
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement