Padroniza os nomes dos códigos Java e C

Mais especificamente, usa o nomes do Java no C.
This commit is contained in:
axell-brendow 2020-08-18 12:25:47 -03:00
parent 597fc3f0d3
commit 9b74306ba1
7 changed files with 27 additions and 108 deletions

View File

@ -1,9 +1,9 @@
#ifndef BUBBLESORT_H
#define BUBBLESORT_H
#ifndef BOLHA_H
#define BOLHA_H
//=============================================================================
#include "sort.h"
#include "geracao.h"
//=============================================================================
void bubbleSort(int *array, int n){
void bolha(int *array, int n){
int i, j;
for (i = (n - 1); i > 0; i--) {
for (j = 0; j < i; j++) {

View File

@ -24,32 +24,32 @@ int main(int argc, char **argv) {
printf("Teste Bolha: Ordem Crescente\n");
crescente(array, n);
print_array(array, n);
mostrar(array, n);
comeco = clock();
bubbleSort(array, n);
bolha(array, n);
fim = clock();
total = (clock() - comeco) / (double)CLOCKS_PER_SEC / 1000.0;
print_array(array, n);
total = (fim - comeco) / (double)CLOCKS_PER_SEC / 1000.0;
mostrar(array, n);
printf("Tempo para ordenar: %f ms (%i).", total, isOrdenado(array, n));
printf("Teste Bolha: Ordem Decrescente\n");
decrescente(array, n);
print_array(array, n);
mostrar(array, n);
comeco = clock();
bubbleSort(array, n);
bolha(array, n);
fim = clock();
total = (clock() - comeco) / (double)CLOCKS_PER_SEC / 1000.0;
print_array(array, n);
total = (fim - comeco) / (double)CLOCKS_PER_SEC / 1000.0;
mostrar(array, n);
printf("Tempo para ordenar: %f ms (%i).", total, isOrdenado(array, n));
printf("Teste Bolha: Ordem Aleatoria\n");
aleatorio(array, n);
print_array(array, n);
mostrar(array, n);
comeco = clock();
bubbleSort(array, n);
bolha(array, n);
fim = clock();
total = (clock() - comeco) / (double)CLOCKS_PER_SEC / 1000.0;
print_array(array, n);
total = (fim - comeco) / (double)CLOCKS_PER_SEC / 1000.0;
mostrar(array, n);
printf("Tempo para ordenar: %f ms (%i).", total, isOrdenado(array, n));
free(array);

View File

@ -1,17 +0,0 @@
#ifndef BUBBLESORT_H
#define BUBBLESORT_H
//=============================================================================
#include "sort.h"
//=============================================================================
void bubbleSort(int *array, int n){
int i, j;
for (i = (n - 1); i > 0; i--) {
for (j = 0; j < i; j++) {
if (array[j] > array[j + 1]) {
swap(&array[j], &array[j + 1]);
}
}
}
}
//=============================================================================
#endif

View File

@ -1,5 +1,5 @@
#ifndef SORT_H
#define SORT_H
#ifndef GERACAO_H
#define GERACAO_H
//=============================================================================
#include <stdio.h>
#include <math.h>
@ -41,7 +41,7 @@ void aleatorio(int *array, int n) {
}
//=============================================================================
// PROCEDIMENTO PARA EXIBIR OS DADOS PRESENTES NO ARRANJO
void print_array(int *array, int n) {
void mostrar(int *array, int n) {
int i;
printf("[ ");
for (i = 0; i < n; i++) {

View File

@ -1,9 +1,9 @@
#ifndef INSERTSORT_H
#define INSERTSORT_H
#ifndef INSERCAO_H
#define INSERCAO_H
//=============================================================================
#include "sort.h"
#include "geracao.h"
//=============================================================================
void insertSort(int *array, int n){
void insercao(int *array, int n){
int i, j, tmp;
for (int i = 1; i < n; i++) {
tmp = array[i];

View File

@ -1,64 +0,0 @@
#ifndef SORT_H
#define SORT_H
//=============================================================================
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
//=============================================================================
// PROCEDIMENTO PARA TROCAR DOIS ELEMENTOS DO VETOR
void swap(int *i, int *j) {
int temp = *i;
*i = *j;
*j = temp;
}
//=============================================================================
// PROCEDIMENTO PARA PREENCHER UM ARRANJO COM ELEMENTOS EM ORDEM CRESCENTE
void crescente(int *array, int n) {
int i;
for (i = 0; i < n; i++) {
array[i] = i;
}
}
//=============================================================================
// PROCEDIMENTO PARA PREENCHER UM ARRANJO COM ELEMENTOS EM ORDEM DECRESCENTE
void decrescente(int *array, int n) {
int i;
for (i = 0; i < n; i++) {
array[i] = n - 1 - i;
}
}
//=============================================================================
// PROCEDIMENTO PARA PREENCHER UM ARRANJO COM ELEMENTOS EM ORDEM ALEATORIA
void aleatorio(int *array, int n) {
int i, pos;
crescente(array, n);
for (i = 0; i < n; i++) {
pos = rand() % n;
swap(&array[i], &array[pos]);
}
}
//=============================================================================
// PROCEDIMENTO PARA EXIBIR OS DADOS PRESENTES NO ARRANJO
void print_array(int *array, int n) {
int i;
printf("[ ");
for (i = 0; i < n; i++) {
printf("%d ", array[i]);
}
printf("] \n");
}
//=============================================================================
// PROCEDIMENTO PARA VERIFICAR SE O ARRANJO ESTA ORDENADO
bool isOrdenado(int *array, int n){
int i;
for(int i = 1; i < n; i++){
if(array[i-1] > array[i]){
return false;
}
}
return true;
}
//=============================================================================
#endif

View File

@ -1,9 +1,9 @@
#ifndef SELECTSORT_H
#define SELECTSORT_H
#ifndef SELECAO_H
#define SELECAO_H
//=============================================================================
#include "sort.h"
#include "geracao.h"
//=============================================================================
void selectSort(int *array, int n){
void selecao(int *array, int n){
int i, j, indice;
for (i = 0; i < (n - 1); i++) {
indice = i;