fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. short i, j, a, n;
  6. a = 0;
  7. n = 0;
  8.  
  9. struct chip {
  10. char name[10]; // Наименование
  11. char type[10]; // Тип
  12. char maker[10]; // Изготовитель
  13. short price; // Цена
  14. } b;
  15. struct chip A[i];
  16.  
  17. for (n = 0; n < 1;){ // Определяет n
  18. printf("Введите колличество микросхем: ");
  19. scanf("%d", &n);
  20. }
  21.  
  22. printf("Введите информацию\n");
  23. for (i=0; i < n; ++i)
  24. { printf("\n Наименование, тип, изготовитель, цена:"); // Заполняет структуру b
  25. scanf("%s%s%s%d", &b.name, &b.type, &b.maker, &b.type);
  26. A[i] = b; // Приравниевает iэлементу массива А структуру b
  27. }
  28.  
  29. for (i = 0; i < n-1; ++i) // Сортирует по цене
  30. for (j = 0; j < n-i-1; ++j)
  31. if (A[j].price > A[j+1].price)
  32. {
  33. a = A[j].price;
  34. A[j].price = A[j+1].price;
  35. A[j+1].price = a;
  36. }
  37.  
  38. for (i=0; i < n; ++i)
  39. printf("%d %s %s %s %d, i, A[i].name, A[i].type, A[i].maker, A[i].price"); // Печатает отсортированные данные
  40. getch();
  41. }
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:19:8: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'short int *' [-Wformat=]
  scanf("%d", &n);
        ^
prog.c:25:10: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[10]' [-Wformat=]
    scanf("%s%s%s%d", &b.name, &b.type, &b.maker, &b.type);
          ^
prog.c:25:10: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'char (*)[10]' [-Wformat=]
prog.c:25:10: warning: format '%s' expects argument of type 'char *', but argument 4 has type 'char (*)[10]' [-Wformat=]
prog.c:25:10: warning: format '%d' expects argument of type 'int *', but argument 5 has type 'char (*)[10]' [-Wformat=]
prog.c:39:10: warning: format '%d' expects a matching 'int' argument [-Wformat=]
   printf("%d %s %s %s %d, i, A[i].name, A[i].type, A[i].maker, A[i].price"); // Печатает отсортированные данные
          ^
prog.c:39:10: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
prog.c:39:10: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
prog.c:39:10: warning: format '%s' expects a matching 'char *' argument [-Wformat=]
prog.c:39:10: warning: format '%d' expects a matching 'int' argument [-Wformat=]
prog.c:40:2: warning: implicit declaration of function 'getch' [-Wimplicit-function-declaration]
  getch();
  ^
prog.c:15:9: warning: 'i' is used uninitialized in this function [-Wuninitialized]
  struct chip A[i];
         ^
/home/UMSbHE/cco0Kdah.o: In function `main':
prog.c:(.text.startup+0x17a): undefined reference to `getch'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty