1
I need to do a work with three modes of ordering in C and I chose a parking system with only the model and the make of the car but I am locked when creating the ordination. I want to take the information of the register and with them to make the ordination.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
char cadastroCarro () {
char modeloCarro[20];
char marcaCarro[20];
int i;
for (i = 0; i < 3; i++) {
printf ("Modelo Carro: ");
scanf ("%s", &modeloCarro[i]);
printf ("\n");
printf ("MarcaCarro: ");
scanf ("%s", &MarcaCarro[k]);
printf ("\n");
}
}
main () {
setlocale(LC_ALL, "Portuguese");
int menu, menuOrdenacao;
printf ("Sistema de Estacionamento");
printf ("\n");
printf ("[1] Cadastro");
printf ("\n");
printf ("[2] Modo de Ordenação");
printf ("\n");
printf ("[3] Sair");
printf ("\n");
printf ("Escolha uma das opções:");
scanf ("%d", &menu);
printf ("\n");
if (menu == 1) {
cadastroCarro();
}
if (menu == 2) {
printf ("Modo de Ordenação");
printf ("\n");
printf ("[1] Bubble Sort");
printf ("\n");
printf ("[2] Selection Sort");
printf ("\n");
printf ("[3] Quick Sort");
printf ("\n");
printf ("Escolha um modo:");
scanf ("%d", &menuOrdenacao);
if (menuOrdenacao == 1) {
// Bubble Sort
}
if (menuOrdenacao == 2) {
// Selection Sort
}
if (menuOrdenacao == 3) {
//QuickSort
}
}
}
First of all your model variablesCarro and Carro should be string arrays and not a single string. Search the Internet by sorting methods and apply your problem. https://pt.wikipedia.org/wiki/Algoritmo_de_sortsort%C3%A7%C3%A3o
– anonimo