daily pastebin goal
3%
SHARE
TWEET

aaa

a guest Feb 13th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define _CRT_SECURE_NO_WARNINGS
  2. //#include <conio.h>
  3. #include <stdio.h>
  4. #include <stdio.h>
  5. #include <math.h>
  6. #include <ctype.h>
  7.  
  8. //#pragma warning(disable:4996)
  9.  
  10. struct sCandy {
  11.     char name[20];
  12.     int weight;
  13.     double price;
  14. };
  15.  
  16. void inputCandies(sCandy *candies, int n)
  17. {
  18.     for (int i = 0; i < n; i++) {
  19.         scanf("%s", candies[i].name);
  20.         scanf("%d", &candies[i].weight);
  21.         scanf("%lf", &candies[i].price);
  22.     }
  23. }
  24.  
  25. void outputCandies(sCandy *candies, int n)
  26. {
  27.     for (int i = 0; i < n; i++)
  28.         printf("\n%s  %d  %4.2lf", candies[i].name, candies[i].weight, candies[i].price);
  29. }
  30.  
  31. int main(void)
  32. {
  33.  
  34.     int n;
  35.     scanf("%d", &n);
  36.     sCandy *candies = new sCandy[n];
  37.  
  38.     inputCandies(candies, n);
  39.     outputCandies(candies, n);
  40.  
  41.     delete[] candies;
  42.  
  43.     getc(stdin);
  44.     return 0;
  45. }
RAW Paste Data
Top