Advertisement
dllbridge

Untitled

Nov 8th, 2023
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.92 KB | None | 0 0
  1.  
  2.  
  3. #include     <stdio.h>
  4.  
  5. int nMonth = 3;
  6.  
  7.  
  8. ////////////////////////////////////////////////////////
  9. int main()                                            //
  10. {
  11.    
  12.    
  13.     switch(nMonth)
  14.     {
  15.        
  16.        case  1:  printf("January\n");
  17.                  break;
  18.  
  19.        case  5:  printf("May\n");
  20.                  break;
  21.                    
  22.        case 12:  printf("December\n");
  23.                  break;    
  24.                    
  25.        default:  printf("Error !\n");                                      
  26.     }
  27.  
  28.  
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  /*
  60.  
  61.  
  62.  
  63.  */
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  // printf("%c\n", 'a');
  70.  
  71.  
  72.     ////////////////////////////////////////////
  73. /*
  74.  
  75.  
  76. #include    <cstdio>
  77. #include   <cstdlib>
  78. #include     <ctime>
  79.  
  80.  
  81. void minimum(int *p);
  82. void maximum(int * );
  83.  
  84.  
  85. /////////////////////////////////    //printf("%d\n", time(0)  );
  86. int main()                     //
  87. {
  88.  
  89.  
  90.    
  91.     srand(time(0));
  92.    
  93.  
  94.  
  95.     int array[20] = {22, 1, 276, 81, 77, 9, 12};
  96.  
  97.  
  98.     int i = 0;
  99.  
  100.     for (; i < 20; i++)
  101.     {
  102.  
  103.         array[i] = rand()%200;
  104.     }
  105.  
  106.     i = 0;
  107.    
  108.    
  109.     for(; i < 20;i++) printf("%d\n", array[i] );
  110.    
  111.    
  112.     printf("\n- - - - - -\n\n");
  113.     minimum(&array[0]);
  114.     maximum(&array[0]);
  115.  
  116.  return 0;
  117.  
  118.  }
  119.  
  120.  
  121.  
  122. /////////////////////////////////////////
  123. void maximum(int *p)                   //    
  124. {
  125.    
  126.     int nMax    = p[0],
  127.         nIndex  = 0;
  128.    
  129.     for(int i = 1; i < 20;i++)
  130.     {
  131.        
  132.         if(nMax < p[i])
  133.         {
  134.              nMax = p[i];
  135.            nIndex =   i ;              
  136.         }
  137.        
  138.     }
  139.    
  140.     printf("Index = %d, Maximum = %d\n", nIndex, nMax);
  141.      
  142. }
  143.  
  144.  
  145.  
  146.  
  147. /////////////////////////////////////////
  148. void minimum(int *p)                   //    
  149. {
  150.    
  151.     int    nMin = p[0],
  152.         nIndex  =   0 ;
  153.    
  154.     for(int i = 1; i < 20;i++)
  155.     {
  156.        
  157.         if(nMin > p[i])
  158.         {
  159.              nMin = p[i];
  160.            nIndex =   i ;
  161.         }
  162.              
  163.        
  164.        
  165.     }
  166.    
  167.     printf("Index = %d, nMin = %d\n", nIndex, nMin);
  168.      
  169. }
  170.  
  171.  
  172.  
  173.  */
  174.  
  175.  
  176.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement