int my_init2(int *pile1, int *pile2, int *s, int r[3][5]) { r[1][0] = my_swap(pile1, s[1], 1); r[1][1] = my_rotate(pile1, s[1], 1); r[1][2] = my_reverse(pile1, s[1], 1); r[2][0] = my_swap(pile2, s[2], -1); r[2][1] = my_rotate(pile2, s[2], -1); r[2][2] = my_reverse(pile2, s[2], -1); return (1); }
void cbCollapseBox::Draw( wxDC& dc ) { cbMiniButton::Draw( dc ); dc.SetPen( *wxTRANSPARENT_PEN ); wxPoint arr[3]; int yOfs = (mPressed) ? 3 : 2; int xOfs = (mPressed) ? 5 : 4; int width = BTN_BOX_WIDTH - 8; // rotating/shifting triangle inside collapse box arr[0].x = xOfs; arr[0].y = yOfs-1; arr[2].x = xOfs; arr[2].y = BTN_BOX_HEIGHT - yOfs - 1; arr[1].x = xOfs + width; arr[1].y = (arr[2].y + arr[0].y)/2; if ( !mIsAtLeft ) { arr[0].x = BTN_BOX_WIDTH - arr[0].x; arr[1].x = BTN_BOX_WIDTH - arr[1].x; arr[2].x = BTN_BOX_WIDTH - arr[2].x; } if ( !mpPane->IsHorizontal() ) { my_swap( arr[0].y, arr[0].x ); my_swap( arr[1].y, arr[1].x ); my_swap( arr[2].y, arr[2].x ); arr[0].x += 1; arr[1].x += 1; arr[2].x += 1; //arr[1].y -= 1; } arr[0].x += mPos.x; arr[0].y += mPos.y; arr[1].x += mPos.x; arr[1].y += mPos.y; arr[2].x += mPos.x; arr[2].y += mPos.y; if ( !mEnabled ) dc.SetBrush( *wxGREY_BRUSH ); else dc.SetBrush( *wxBLACK_BRUSH ); dc.DrawPolygon( 3, arr ); dc.SetBrush( wxNullBrush ); }
int p_a(int *l_a, int *l_b, int argc) { int i; i = argc - 1; if (l_b == NULL) return (0); my_swap(&l_b[0], &l_a[i]); while (i > 0) { my_swap(&l_a[i - 1], &l_a[i]); i--; } my_putstr("p_a "); }
void my_sort_int_tab(int *tab, int size) { int i; int ordered; int *c1; int j; i = 0; ordered = 0; while ((i < size) & !ordered) { c1 = tab; j = 0; ordered = 1; while (c1 - tab < size - 1) { if (*c1 > *(c1 + 1)) { ordered = 0; my_swap(c1, c1 + 1); } c1++; } i++; } }
int ilistsort(t_mls *begin, int (*el_cmp)(t_mls *, t_mls *)) { int n; int i; int j; int k; t_mls *cpy; if (begin == NULL || el_cmp == NULL || (n = countlist(begin)) <= 0) return (MERROR); i = 0; while (++i < n) { j = i; cpy = begin; k = -1; while (++k != i) cpy = cpy->next; while (cpy->prev != NULL && j > 0 && el_cmp(cpy, cpy->prev) < 0) { my_swap(cpy, cpy->prev); --j; cpy = cpy->prev; } } return (MTRUE); }
void build_max_heap(int A[], int size) { my_swap(&A[0], &A[size-1]); int i = size/2; for (; i >= 0; i--) max_heapify(A, i, size); }
void heap_sort(int A[], int size) { build_max_heap(A, size); int i = size-1; for (; i >= 1; i--) { my_swap(&A[0], &A[i]); max_heapify(A, 0, i); } }
void my_horline(int y, int a, int b, t_color *color, t_bunny_pixelarray *pix) { if (a > b) my_swap(&a, &b); while (a < b) { tekpixel_coord(pix, a, y, color); a = a + 1; } }
void Mjoin(PATL,tstsqtran)(const int N, TYPE *A, const int lda0) /* * transposes the square matrix A, easiest (and slowest) algorithm possible */ { const int lda=(lda0 SHIFT), ldap1=lda0+1; int i; for (i=1; i < N; i++) my_swap(N-i, A+(i SHIFT), ldap1, A+i*lda, ldap1); }
int main() { int a; int b; int *pointeura; int *pointeurb; *pointeura=$a; *pointeurb=$b; my_swap(*pointeura, *pointeurb); }
void my_sort_int_tab(int *tab, int size) { int loop; int *v2; loop = 0; while (loop < size) { v2 = the_litlest(tab, size, loop); my_swap(&tab[loop], v2); ++loop; } }
/* ** reverse a string */ char *my_revstr(char *str) { int length; char c; c = 0; length = my_strleng(str); while (length >= c) { length = length - 1; my_swap(&str[c], &str[length]); c = c + 1; } return (str); }
int my_sort_int_tab(int *tab, int size) { int i; i = 0; while (i < size) { if (tab[i] > tab[i + 1]) { my_swap(&tab[i], &tab[i + 1]); } i = i + 1; } return (i); }
void reverse(char *str) { int i; int j; i = 0; j = my_len(str) - 1; while (i < j) { my_swap(&str[i], &str[j]); i++; j--; } fprintf(stdout, "string reversed: [%s]\n", str); }
char *my_revstr(char *str) { int count; int a; a = 0; count = my_strlen(str) - 1; while(count != a && a != (count + 1)) { my_swap(&str[a], &str[count]); count = count - 1; a = a + 1; } return (str); }
char *my_revstr(char *str) { int count; int len; int tmp; count = 0; len = my_strlen(str); while ( count < len / 2) { my_swap(str + count, str + len - count - 1); count = count + 1; } my_putstr(str); }
void max_heapify(int A[], int i, int size) { int l = LEFT(i); int r = RIGHT(i); int largest = i; if (l < size && A[l] > A[i]) largest = l; if (r < size && A[r] > A[largest]) largest = r; if (largest != i) { my_swap(&A[i], &A[largest]); max_heapify(A, largest, size); } }
void my_verline(int x, int a, int b, t_color *color, t_bunny_pixelarray *pix) { unsigned *pixels; pixels = (unsigned *)pix->pixels; if (a > b) my_swap(&a, &b); if (a < 0 || b > S_HEIGHT) { a = 0; b = S_HEIGHT; } while (a < b) { pixels[ABS((x + (a * S_WIDTH)))] = color->full; a = a + 1; } }
char *my_evil_str(char *str) { int i; int j; char str2[1]; i=0; while (str[i] != '\0') { i++; } i = i - 1; j=0; while (j < i) { my_swap(str[i], str[j]); i++; j--; } return (str); }
void my_sort_int_tab(int *tab, int size) { int i; int moves; moves = 1; while (moves > 0 && tab && size > 0) { i = 0; moves = 0; while (i < size) { if (i < size - 1 && tab[i + 1] < tab[i]) { my_swap(&tab[i], &tab[i + 1]); moves = moves + 1; } i = i + 1; } } }
/* ** my_sort_int_tab.c for my_sort_int_tab in /home/faure_j//rendu/lib/my ** ** Made by jordan faure ** Login <*****@*****.**> ** ** Started on Mon Oct 24 10:36:44 2011 jordan faure ** Last update Fri Oct 28 11:35:14 2011 jordan faure */ int my_sort_int_tab(int *tab, int size) { int modif; int pos; modif = 1; while (modif == 1) { pos = 0; modif = 0; while (pos < (size - 1)) { if (tab[pos] > tab[pos + 1]) { my_swap(tab + pos, tab + pos + 1); modif = 1; } pos = pos + 1; } } }
void my_sort_int_tab(int *tab, int size) { int chang; int compt; chang = 1; while (chang != 0) { compt = 0; chang = 0; while (compt != (size)) { if (*(tab + compt) < *((tab + compt) + 1)) { my_swap((tab + compt), ((tab + compt) + 1)); chang = chang + 1; } compt = compt + 1; } } }
void my_sort_int_tab(int *tab, int size) { int i; int j; int k; i = 0; j = 0; k = 0; while (k < size) { while (j < size) { if (tab[j] == i) { my_swap(&tab[j], &tab[k]); k = k + 1; } j = j + 1; } j = k; i = i + 1; } }
void my_sort_int_tab(int *tab, int size) { int i; int sort; int nb; nb = 0; sort = 0; while (sort == 0) { i = 0; sort = 1; while ((i + 1) < size) { if (tab[i] > tab[i + 1]) { sort = 0; my_swap(&tab[i], &tab[i + 1]); } i = i + 1; } nb++; } }
int *s_b(int *l_b) { my_swap(&l_b[0], &l_b[1]); my_putstr("s_b "); }
int main() { Iterator my_iter; List my_list; my_list.head = NULL; int c, val = 0, pos, k, ans; bool flag = false; helper(); while ((c = getchar()) != EOF) { flag = false; switch (c) { case 'c': if (list_Create(&my_list)) { printf("List is already created \n"); break; } Create(&my_list); break; case 'e': if (!list_Create(&my_list)) { printf("List isn't created \n"); break; } if (Empty(&my_list) == 1) { printf("List is empty\n"); break; } printf("List isn`t empty\n"); break; case 'h': helper(); break; case 'i': getchar(); my_getint(&pos, &flag); if (!flag) { printf("You havn`t entered index. Try again.\n"); break; } my_getint(&val, &flag); if (!flag) { printf("You havn`t entered value. Try again.\n"); break; } if (!list_Create(&my_list)) { printf("List isn't created \n"); break; } if (!find_Items_Index(&my_list, &my_iter, pos)) { printf("Error. Not found items index: %d\n", pos); break; } Insert(&my_list, &my_iter, val); break; case 's': getchar(); if (Empty(&my_list) == 1) { printf("Error: List is empty!\n"); break; } my_getint(&k, &flag); if (!flag) { printf("You havn`t entered index. Try again.\n"); break; } if (k < 0) { k = k % Size(&my_list); k = Size(&my_list) + k % Size(&my_list) + 1; } if (k > Size(&my_list)) k = k % Size(&my_list); if (!list_Create(&my_list)) { printf("List isn't created \n"); break; } find_Items_Index(&my_list, &my_iter, k); my_swap(&my_list, &my_iter); break; case 'p': if (!list_Create(&my_list)) { printf("List isn't created \n"); break; } print_List(&my_list); break; case 'd': getchar(); my_getint(&val, &flag); if (!flag) { printf("You havn`t entered value. Try again.\n"); break; } if (!list_Create(&my_list)) { printf("List isn't created \n"); break; } if (!find_Items_Data(&my_list, &my_iter, val)) { printf("Error. Not found items data: %d\n", pos); break; } Delete(&my_list, &my_iter); break; case 'l': if (!list_Create(&my_list)) { printf("List isn't created \n"); break; } ans = length_of_List(&my_list); if (ans != -1) printf("Length list: %d \n", ans); break; case '0': if (list_Create(&my_list)) Destroy(&my_list); break; case 'x': if (list_Create(&my_list)) Destroy(&my_list); break; } } }
void draw_line(SDL_Surface *screen, cood c1, cood c2, Uint32 color) { int x0 = c1.getx(); int y0 = c1.gety(); int x1 = c2.getx(); int y1 = c2.gety(); int x, y; cood p; putpixel(screen, x, y, color); if( x0 == x1 ) { if( y0 < y1) for( y = y0; y <= y1; y++ ) { x = x0; p.putx(x); p.puty(y); putpixel(screen, x, y, color); } else for( y = y1; y <= y0; y++ ) { x = x0; p.putx(x); p.puty(y); putpixel(screen, x, y, color); } } else if( y0 == y1 ) { if(x0 < x1) for( x = x0; x <= x1; x++ ) { y = y0; p.putx(x); p.puty(y); putpixel(screen, x, y, color); } else for( x = x1; x <= x0; x++ ) { y = y0; p.putx(x); p.puty(y); putpixel(screen, x, y, color); } } else { bool steep = ((fabs(y1 - y0) > fabs(x1 - x0)) ? 1:0); if(steep) { my_swap(x0,y0); my_swap(x1,y1); } if(x0 >x1) { my_swap(x0,x1); my_swap(y0,y1); } int dErr = fabs(y1 - y0); int ystep = y0 > y1 ? -1 : 1; int dx = x1 - x0; int err = dx >> 1; int y = y0; for( int x = x0; x<=x1; x++) { if(steep) { p.putx(y); p.puty(x); putpixel(screen, x, y, color); } else { p.putx(x); p.puty(y); putpixel(screen, x, y, color); } err -= dErr; if(err < 0) { y += ystep; err += dx; } } } }
void f() { int i, j; my_swap(i, j); }
int *s_a(int *l_a) { my_swap(&l_a[0], &l_a[1]); my_putstr("s_a "); }