ChorongBias

Untitled

Jan 11th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. {
  2. int i, k, choice, array[SIZE], j, temp;
  3. printf("Select a Road User\n");
  4. printf("1)Pedestrian\n2)Motor Cyclists\n3)Motor Car\n4)Light Truck\n5)Truck\n");
  5. scanf_s(" %d", &choice);
  6. if (choice == 1)
  7. {
  8. printf("Enter the amount of numbers\n");
  9. scanf_s("%d", &k);
  10. printf("Please enter the numbers one by one \n");
  11. for (i = 0; i < k; i++)
  12. {
  13. scanf_s("%d", &array[i]);
  14. }
  15. for (i = 0; i < k; i++)
  16. {
  17. printf("%d\n", array[i]);
  18. }
  19. for (i = 0; i < k; i++)
  20. {
  21. for (j = 0; j < (k - i - 1); j++)
  22. {
  23. if (array[j] < array[j + 1])
  24. {
  25. temp = array[j];
  26. array[j] = array[j + 1];
  27. array[j + 1] = temp;
  28.  
  29. }
  30. }
  31. }
  32. printf("The sorted array for Pedestrians in descending order is \n");
  33. for (i = 0; i < k; i++)
  34. {
  35. printf("%d\n", array[i]);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment