Guest User

Untitled

a guest
Feb 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. struct float_tuple
  6. {
  7.     float x;
  8.     float y;
  9. };
  10.  
  11. static int test1 (int a, int b, int c, int x);
  12. static int test2 (int a, int b, int c, int x);
  13. static struct float_tuple* test3 (float a, float b, float c);
  14. static int test4 (float a, float b, float c);
  15. static int test5 (int a, int b);
  16. static int test6 (int a, int b);
  17. static int test7 (int a, int b, int c);
  18. static int test8 (int a, int b, int c);
  19. static int test9 (char a);
  20. static int test10 (char a);
  21. static int test11 (char a);
  22. static char test12 (char a);
  23.  
  24. int main (int argc, char* argv[])
  25. {
  26.     int a,b,c,x;
  27.     char d,e;
  28.  
  29.     int quad, quadisZero, realRoots, bigger, smaller, biggestOf3, smallestOf3;
  30.     int isADigit, isAlphabetic, digitCharToInt;
  31.  
  32.     char lowerToUpper;
  33.  
  34.     struct float_tuple* quadratic_solver;
  35.  
  36.     sscanf(argv[0],"%d",&a);
  37.     sscanf(argv[1],"%d",&b);
  38.     sscanf(argv[2],"%d",&c);
  39.     sscanf(argv[3],"%d",&x);
  40.     sscanf(argv[4],"%c",&d);
  41.     sscanf(argv[5],"%c",&e);
  42.  
  43.  
  44.     quad = test1(a, b, c, x);
  45.     quadisZero = test2(a, b, c, x);
  46.     quadratic_solver = test3((float)a, (float)b, (float)c);
  47.     realRoots = test4((float)a, (float)b, (float)c);
  48.     bigger = test5(a, b);
  49.     smaller = test6(a, b);
  50.     biggestOf3 = test7(a, b, c);
  51.     smallestOf3 = test8(a, b, c);
  52.     isADigit = test9(d);
  53.     isAlphabetic = test10(d);
  54.     digitCharToInt = test11(d);
  55.     lowerToUpper = test12(e);
  56. }
  57.  
  58. static int test1 (int a, int b, int c, int x) { return ((a * x * x) + (b * x) + c); }
  59. static int test2 (int a, int b, int c, int x) { return !test1(a,b,c,x); }
  60. static struct float_tuple* test3 (float a, float b, float c)
  61. {
  62.     struct float_tuple* value = (struct float_tuple*)malloc(sizeof(struct float_tuple));
  63.  
  64.     float root = sqrt((b*b) - 4 * a * c);
  65.  
  66.     value->x = ((-b + root)/(2 * a));
  67.  
  68.     value->y = ((-b - root)/(2 * a));
  69.  
  70.     return value;
  71.  
  72. }
  73. static int test4 (float a, float b, float c)
  74. {
  75.         return (((b*b) - 4 * a * c) >= 0.0);
  76. }
  77. static int test5 (int a, int b) { return ((a > b) ? a : b); }
  78. static int test6 (int a, int b) { return ((a < b) ? a : b); }
  79. static int test7 (int a, int b, int c) { return test5(test5(a,b),c); }
  80. static int test8 (int a, int b, int c) { return test6(test6(a,b),c); }
  81. static int test9 (char a) { return ((((int)'0') <= (int)a) && ((int)a <= (int)'9')); }
  82. static int test10 (char a) { return ((((int)'a') <= (int)a) && ((int)a <= (int)'Z')); }
  83. static int test11 (char a) { return (test9(a) ? atoi(&a) : 0); }
  84. static char test12 (char a) { return (((((int)'a') <= (int)a) && ((int)a <= (int)'z')) ? ((char)(26 + (int)a)) : 'A'); }
Add Comment
Please, Sign In to add comment