Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- int i, k, choice, array[SIZE], j, temp;
- printf("Select a Road User\n");
- printf("1)Pedestrian\n2)Motor Cyclists\n3)Motor Car\n4)Light Truck\n5)Truck\n");
- scanf_s(" %d", &choice);
- if (choice == 1)
- {
- printf("Enter the amount of numbers\n");
- scanf_s("%d", &k);
- printf("Please enter the numbers one by one \n");
- for (i = 0; i < k; i++)
- {
- scanf_s("%d", &array[i]);
- }
- for (i = 0; i < k; i++)
- {
- printf("%d\n", array[i]);
- }
- for (i = 0; i < k; i++)
- {
- for (j = 0; j < (k - i - 1); j++)
- {
- if (array[j] < array[j + 1])
- {
- temp = array[j];
- array[j] = array[j + 1];
- array[j + 1] = temp;
- }
- }
- }
- printf("The sorted array for Pedestrians in descending order is \n");
- for (i = 0; i < k; i++)
- {
- printf("%d\n", array[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment