normed
This commit is contained in:
		| @ -6,12 +6,25 @@ | |||||||
| /*   By: cchauvet <cchauvet@student.42angouleme.fr  +#+  +:+       +#+        */ | /*   By: cchauvet <cchauvet@student.42angouleme.fr  +#+  +:+       +#+        */ | ||||||
| /*                                                +#+#+#+#+#+   +#+           */ | /*                                                +#+#+#+#+#+   +#+           */ | ||||||
| /*   Created: 2022/12/09 14:24:03 by cchauvet          #+#    #+#             */ | /*   Created: 2022/12/09 14:24:03 by cchauvet          #+#    #+#             */ | ||||||
| /*   Updated: 2022/12/09 19:11:58 by cchauvet         ###   ########.fr       */ | /*   Updated: 2022/12/09 19:14:50 by cchauvet         ###   ########.fr       */ | ||||||
| /*                                                                            */ | /*                                                                            */ | ||||||
| /* ************************************************************************** */ | /* ************************************************************************** */ | ||||||
|  |  | ||||||
| #include "pushswap.h" | #include "pushswap.h" | ||||||
|  |  | ||||||
|  | static void	ft_specific_bozo_sort(t_tab tab_a, t_tab tab_b) | ||||||
|  | { | ||||||
|  | 	if (tab_a[0] == tab_a[1] - 1) | ||||||
|  | 		ft_rra(tab_a); | ||||||
|  | 	if (tab_a[0] == tab_a[1] + 1 && tab_a[1] == tab_a[2] + 1) | ||||||
|  | 	{ | ||||||
|  | 		ft_ra(tab_a); | ||||||
|  | 		ft_sa(tab_a); | ||||||
|  | 	} | ||||||
|  | 	if (tab_a[0] == tab_a[1] + 1) | ||||||
|  | 		ft_sa(tab_a); | ||||||
|  | } | ||||||
|  |  | ||||||
| void	ft_bozo_sort(t_tab tab_a, t_tab tab_b) | void	ft_bozo_sort(t_tab tab_a, t_tab tab_b) | ||||||
| { | { | ||||||
| 	if (ft_is_sorted(tab_a)) | 	if (ft_is_sorted(tab_a)) | ||||||
| @ -22,15 +35,6 @@ void	ft_bozo_sort(t_tab tab_a, t_tab tab_b) | |||||||
| 			ft_ra(tab_a); | 			ft_ra(tab_a); | ||||||
| 		ft_pb(tab_a, tab_b); | 		ft_pb(tab_a, tab_b); | ||||||
| 	} | 	} | ||||||
| 	if (tab_a[0] == tab_a[1] - 1) |  | ||||||
| 		ft_rra(tab_a); |  | ||||||
| 	if (tab_a[0] == tab_a[1] + 1 && tab_a[1] == tab_a[2] + 1) |  | ||||||
| 	{ |  | ||||||
| 		ft_ra(tab_a); |  | ||||||
| 		ft_sa(tab_a); |  | ||||||
| 	} |  | ||||||
| 	if (tab_a[0] == tab_a[1] + 1) |  | ||||||
| 		ft_sa(tab_a); |  | ||||||
| 	if (!ft_is_sorted(tab_a)) | 	if (!ft_is_sorted(tab_a)) | ||||||
| 	{ | 	{ | ||||||
| 		ft_pb(tab_a, tab_b); | 		ft_pb(tab_a, tab_b); | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								ft_s.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								ft_s.c
									
									
									
									
									
								
							| @ -6,18 +6,18 @@ | |||||||
| /*   By: cchauvet <cchauvet@student.42angouleme.fr  +#+  +:+       +#+        */ | /*   By: cchauvet <cchauvet@student.42angouleme.fr  +#+  +:+       +#+        */ | ||||||
| /*                                                +#+#+#+#+#+   +#+           */ | /*                                                +#+#+#+#+#+   +#+           */ | ||||||
| /*   Created: 2022/12/09 18:00:12 by cchauvet          #+#    #+#             */ | /*   Created: 2022/12/09 18:00:12 by cchauvet          #+#    #+#             */ | ||||||
| /*   Updated: 2022/12/09 18:05:06 by cchauvet         ###   ########.fr       */ | /*   Updated: 2022/12/09 19:15:57 by cchauvet         ###   ########.fr       */ | ||||||
| /*                                                                            */ | /*                                                                            */ | ||||||
| /* ************************************************************************** */ | /* ************************************************************************** */ | ||||||
|  |  | ||||||
| #include "pushswap.h" | #include "pushswap.h" | ||||||
|   |  | ||||||
| static void ft_s (t_tab tab) | static void	ft_s(t_tab tab) | ||||||
| { | { | ||||||
| 	ft_swap(tab + 0, tab + 1); | 	ft_swap(tab + 0, tab + 1); | ||||||
| } | } | ||||||
|  |  | ||||||
| void ft_sa(t_tab tab) | void	ft_sa(t_tab tab) | ||||||
| { | { | ||||||
| 	ft_s(tab); | 	ft_s(tab); | ||||||
| 	ft_putstr("sa\n"); | 	ft_putstr("sa\n"); | ||||||
|  | |||||||
							
								
								
									
										29
									
								
								test.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								test.c
									
									
									
									
									
								
							| @ -1,29 +0,0 @@ | |||||||
| /* ************************************************************************** */ |  | ||||||
| /*                                                                            */ |  | ||||||
| /*                                                        :::      ::::::::   */ |  | ||||||
| /*   test.c                                             :+:      :+:    :+:   */ |  | ||||||
| /*                                                    +:+ +:+         +:+     */ |  | ||||||
| /*   By: cchauvet <cchauvet@student.42angouleme.fr  +#+  +:+       +#+        */ |  | ||||||
| /*                                                +#+#+#+#+#+   +#+           */ |  | ||||||
| /*   Created: 2022/12/07 13:38:08 by cchauvet          #+#    #+#             */ |  | ||||||
| /*   Updated: 2022/12/07 14:14:21 by cchauvet         ###   ########.fr       */ |  | ||||||
| /*                                                                            */ |  | ||||||
| /* ************************************************************************** */ |  | ||||||
|  |  | ||||||
| #include "pushswap.h" |  | ||||||
|  |  | ||||||
| int	main() |  | ||||||
| { |  | ||||||
| 	unsigned int	tab_a[10] = {0, 1, 2, 3, 4, STOP_VALUE}; |  | ||||||
| 	unsigned int	tab_b[10] = {5, STOP_VALUE}; |  | ||||||
| 	int				i; |  | ||||||
|  |  | ||||||
| 	printf("tab_a\n"); |  | ||||||
| 	i = 0; |  | ||||||
| 	while (tab_a[i] != STOP_VALUE) |  | ||||||
| 		printf("%d\n", tab_a[i++]); |  | ||||||
| 	ft_pa(tab_a, tab_b); |  | ||||||
| 	i = 0; |  | ||||||
| 	while (tab_a[i] != STOP_VALUE) |  | ||||||
| 		printf("%d\n", tab_a[i++]); |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user