Advertisement
nontawat1996

จัดห้องพี่เต้ย

Nov 3rd, 2011
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int c[100]= {0},d[100]= {0},i,j,a,b,max=0;
  7.     char s=' ',x[4],y[4];
  8.     for (i=0;i<1;i++)
  9.     {scanf ("%s %s",&x,&y);}
  10.  
  11.     //{printf("%s%s",x,y);}
  12.     printf("PLz input number of student.");
  13.     scanf("%d %d",&a,&b);
  14.     if (a>=b)
  15.     {max=a;}
  16.     else
  17.     {
  18.         max=b;
  19.     }
  20.     printf("Test room for %s and %s\n",x,y);
  21.     for (i=1; i<=a; i++)
  22.     {
  23.         c[i]=i;
  24.     }
  25.     for (i=1; i<=b; i++)
  26.     {
  27.         d[i]=i;
  28.     }
  29.  
  30.  
  31.  
  32.  
  33.     //printf("%d",c[5]);
  34.  
  35.     printf ("\t\troom 1\n");
  36.     printf("\t\tfrom number 01 to 25\n");
  37.     for (i=1; i<=25; i++)
  38.     {
  39.         if (d[i]==0&&c[i]==0)
  40.         {
  41.             printf("%3c- %2c-",s,s);
  42.         }
  43.         else
  44.         if (c[i]==0)
  45.         {
  46.             printf("%3c-  %2d",s,d[i]);
  47.         }
  48.  
  49.         else if (d[i]==0)
  50.         {
  51.             printf("%5d %c-",c[i],s);
  52.         }
  53.         else
  54.         {
  55.             printf("%5d %2d",c[i],d[i]);
  56.         }
  57.         if (i%5==0)
  58.         {
  59.             printf("\n");
  60.         }
  61.     }
  62.     if (c[i]<26&&d[i]<26)
  63.     return 0;
  64.     printf("\t\troom 2\n");
  65.  
  66.     printf("\t\tfrom number 26 to %d\n",max);
  67.     for (i=26; i<=50; i++)
  68.     {
  69.         if (d[i]==0&&c[i]==0)
  70.         {
  71.             printf("%3c- %2c-",s,s);
  72.         }
  73.         else if (c[i]==0)
  74.         {
  75.             printf("%3c-  %2d",s,d[i]);
  76.         }
  77.         else if (d[i]==0)
  78.  
  79.         {
  80.             printf("%5d %c-",c[i],s);
  81.         }
  82.         else
  83.         {
  84.             printf("%5d %2d",c[i],d[i]);
  85.         }
  86.         if (i%5==0)
  87.         {
  88.             printf("\n");
  89.         }
  90.     }
  91.     scanf(" ");
  92.     return 0;
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement