Created
          October 1, 2012 15:35 
        
      - 
      
- 
        Save JaHIY/3812547 to your computer and use it in GitHub Desktop. 
    C:calculate bust size by cup size
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| /* | |
| * Usage: ./cup your_cup_size your_underbust_size | |
| * | |
| * for example: | |
| * ./cup B 75 | |
| * | |
| * then you will get: | |
| * CUP: B75 >>> 73.00 <= underbust <= 77.00, 87.00 <= bust <= 93.00 (unit: cm) | |
| * | |
| * */ | |
| double get_underbust_min(int underbust_size) { | |
| return underbust_size - 2.0; | |
| } | |
| double get_underbust_max(int underbust_size) { | |
| return underbust_size + 2.0; | |
| } | |
| double get_bust_delta_min(int cup_size, int underbust_size) { | |
| return 10.0 + 2*cup_size; | |
| } | |
| double get_bust_delta_max(int cup_size, int underbust_size) { | |
| return 12.0 + 2*cup_size; | |
| } | |
| int main(int argc, char *argv[]) { | |
| int csize, ubsize; | |
| double ubmin, ubmax; | |
| size_t csize_len; | |
| if (argc != 3) { | |
| fprintf(stderr, "Usage: %s your_cup_size your_underbust_size\n", argv[0]); | |
| return 1; | |
| } | |
| csize_len = strlen(argv[1]); | |
| if (csize_len == 1 && *argv[1] >= 65 && *argv[1] <= 90) { | |
| csize = (*argv[1]) - 64; | |
| } else if (csize_len == 2 && strcmp(argv[1], "AA") == 0) { | |
| csize = 0; | |
| } else { | |
| fprintf(stderr, "Error: \"%s\" - cup size is invalid!\n", argv[1]); | |
| return 2; | |
| } | |
| ubsize = atoi(argv[2]); | |
| if (ubsize > 62) { | |
| ubmin = get_underbust_min(ubsize); | |
| ubmax = get_underbust_max(ubsize); | |
| printf("CUP: %s%s >>> %.2f <= underbust <= %.2f, %.2f <= bust <= %.2f (unit: cm)\n", argv[1], argv[2], ubmin, ubmax, ubmin + get_bust_delta_min(csize, ubsize), ubmax + get_bust_delta_max(csize, ubsize)); | |
| } else { | |
| fprintf(stderr, "Error: your underbust is too little!\n"); | |
| return 3; | |
| } | |
| return 0; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment