Exemplo n.º 1
0
int main(int argc, char **argv) {
 
  big_int b = big_int_init();
  big_int_insert(b, 30045);
  big_int_print(b);
  printf("Size: %d\n", big_int_digits(b));
  big_int_reverse(b);
  big_int_print(b);

  return 0;
}
Exemplo n.º 2
0
Arquivo: sort.c Projeto: chobaeks/Exam
int
main (int    argc,
      char **argv)
{
  int option;
  int minusfind;
  int sizecompare;
  char *minusdelete_first;
  char *minusdelete_second;
  char *plus;
  char *minus;

  option = big_int_option (argc, argv);

  switch (option)
    {
    case 1 : minusfind = big_int_minusfind (argv[2], argv[3]); 
             switch (minusfind)
               {
               case 1 : plus = big_int_plus (argv[2], argv[3]);
                        big_int_print (plus);
                        return 0;
               case 2 : minusdelete_first = big_int_minusdelete (argv[2]);
                        minusdelete_second = big_int_minusdelete (argv[3]);
                        plus = big_int_plus (minusdelete_first, minusdelete_second);
                        printf ("-");
                        big_int_print (plus);
                        return 0;
               case 3 : minusdelete_first = big_int_minusdelete (argv[2]);
                        sizecompare = big_int_sizecompare (minusdelete_first, argv[3]);
                        switch (sizecompare)
                          {
                          case 0 : printf ("0\n");
                                   return 0;
                          case 1 : minus = big_int_minus (minusdelete_first, argv[3]);
                                   printf ("-");
                                   big_int_print (minus);
                                   return 0;
                          case 2 : minus = big_int_minus (argv[3], minusdelete_first);
                                   big_int_print (minus);
                                   return 0;
                          }
               case 4 : minusdelete_second = big_int_minusdelete (argv[3]);
                        sizecompare = big_int_sizecompare (argv[2], minusdelete_second);
                        switch (sizecompare)
                          {
                          case 0 : printf ("0\n");
                                   return 0;
                          case 1: minus = big_int_minus (argv[2], minusdelete_second);
                                  big_int_print (minus);
                                  return 0;
                          case 2: minus = big_int_minus (minusdelete_second, argv[2]);
                                  printf ("-");
                                  big_int_print (minus);
                                  return 0;
                          }
               }
             break;
    case 2 : minusfind = big_int_minusfind (argv[2], argv[3]); 
             switch (minusfind)
               {
               case 1 : sizecompare = big_int_sizecompare (argv[2], argv[3]);
                        switch (sizecompare)
                          {
                          case 0 : printf ("0\n");
                                   return 0;
                          case 1 : minus = big_int_minus (argv[2], argv[3]);
                                   big_int_print (minus);
                                   return 0;
                          case 2 : minus = big_int_minus (argv[3], argv[2]);
                                   big_int_print (minus);
                                   return 0;
                          }
               case 2 : minusdelete_first = big_int_minusdelete (argv[2]);
                        minusdelete_second = big_int_minusdelete (argv[3]);
                        sizecompare = big_int_sizecompare (minusdelete_first, minusdelete_second);
                        switch (sizecompare)
                          {
                          case 0 : printf ("0\n");
                                   return 0;
                          case 1 : minus = big_int_minus (minusdelete_first, minusdelete_second);
                                   printf ("-");
                                   big_int_print (minus);
                                   return 0;
                          case 2 : minus = big_int_minus (minusdelete_second, minusdelete_first);
                                   big_int_print (minus);
                                   return 0;
                          }
               }
    case 3 : 
             break;
    }

 
/*
  int firststrlen_temp;
  int secondstrlen_temp;
  int compare_result;
  int sort_minuscompare;
  int minusi_temp;
  firststrlen_temp = strlen (argv[1]);
  secondstrlen_temp = strlen (argv[2]);
  sort_minuscompare = sort_minuscompare_temp(argv[1], argv[2]);

  compare_result = sort_compare (firststrlen_temp, secondstrlen_temp); //크기 비교. 크기가 같으면 0 argv[1] 이 크면 1 argv[2] 가 크면 2가 반환된다.
  sort_plus (firststrlen_temp, secondstrlen_temp); //덧셈하는 함수.
  minusi_temp = sort_minus (compare_result); //뺄셈하는 함수
  sort_print (minsi_temp, compare_result); //출력하는 함수.

  sort_free ();
 */

  return 0;
}