Advertisement
Mary_99

task1

Jan 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.89 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6.  
  7. int main(int argc, char *argv[]) {
  8.  
  9.     int N, M;
  10.     int i, j ,probability;
  11.     char a;
  12.     char b;
  13.    
  14.     printf("Enter the number of rows: \n");
  15.     scanf(" %d", &N);
  16.     printf("Enter the number of columns: \n");
  17.     scanf(" %d", &M);
  18.    
  19.     printf("\nEnter first character");
  20.     scanf(" %c", &a);
  21.     printf("\nEnter second characters");
  22.     scanf(" %c", &b);
  23.  
  24.     while(isdigit(a) || isdigit(b))//check if sine is a digit
  25.     {
  26.         printf("\nEnter two characters");
  27.         scanf(" %c %c", &a, &b);
  28.     }
  29.    
  30.     for (i= 0; i<N; i++)
  31.     {
  32.         for(j=0; j<M; j++)
  33.         {
  34.             probability=rand()%10; //probability about 1 of 10
  35.             if(probability==1) //probilityy = 1
  36.             {
  37.                 printf("%c", a);
  38.             }
  39.             else
  40.                 {
  41.                     printf("%c", b);   
  42.                 }
  43.                
  44.         }
  45.         printf("\n");
  46.     }
  47.    
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement