<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. int upgrade, i,j,k;
  5. int PN, CN, min, yu, mo;//define variable
  6. char* p;
  7.  
  8. int main()
  9. {
  10.    char str[10];
  11.    printf("please input the number of pigdey and candy(3digital):\n");//3 digital number input required
  12. start: gets(str);//program start
  13.    strlen(str);
  14.    if (strlen(str) > 7||strlen(str) <2)
  15.    {
  16.       printf("input invalid ,please input again:\n");
  17.       goto start;
  18.    }
  19.     if ((str[1]==' ')||(str[4]==' ')){
  20.       printf("input invalid ,please input again:\n");
  21.    goto start;}
  22.    char c[] = " ";
  23.    p= strtok(str, c);
  24.    for (i=0;i<3;i++){
  25.       if ((p[i]>='0') && (p[i]<='9'))
  26.          goto cont;
  27.    else goto error;}
  28. cont: printf("your PN is %s\n", p);
  29.    PN = atoi(p);
  30.     p = strtok(NULL, c);
  31.    if (p)   
  32.    goto lb;
  33. error: printf("input error,please input again:\n");
  34.    goto start;
  35. lb:printf("your candy is %s\n", p);
  36.    for (j=0;j<3;j++)
  37.    {
  38.       if ((p[j]>='0') && (p[j]<='9'))
  39.       p[j];
  40.           else goto error2;
  41.    }
  42.        CN = atoi(p);
  43.       p = strtok(NULL, c);
  44.       if(p)
  45. error2:  {printf("input invalid,please input again:\n");
  46.    goto start;
  47.    }
  48.    mo = CN - 24;
  49.    if (mo > 0) {
  50.       upgrade = 1000;
  51.       min = mo / 12;
  52.       goto label;
  53.    }
  54.    else
  55.       min = CN / 12;
  56.    yu = CN % 12;
  57.    goto finnal;
  58. label:yu = mo % 12;
  59. finnal:printf("the max exp is %d.\n", (100 * yu + (min * 500) + upgrade + (PN * 55)));
  60.     return 0;
  61. }