tungggg

string

Jun 7th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1.  
  2.  
  3.        
  4.  
  5. #include <stdio.h>
  6. #include<string.h>
  7. #include<math.h>
  8.  
  9. #define maxn 1000
  10.  
  11. int max ( int a , int b ){
  12.     if ( a > b ) return a ;
  13.     return b ;
  14. }
  15.  
  16. int main()
  17. {
  18.     int row, col ;
  19.     scanf("%d",&row) ;
  20.     scanf("%d",&col) ;
  21.    
  22.     char a='a';
  23.     char start = a+max(row,col)-1;
  24.     char temp[maxn]="";
  25.     for (int i=1;i<=row;i++){
  26.         char thisLine[maxn];
  27.         for (int j=0;j<i-1;j++){
  28.             thisLine[j]=temp[j];
  29.         }
  30.         for (int j=i;j<=col;j++){
  31.             thisLine[j-1]=start ;
  32.         }
  33.         for (int j=0;j<strlen(thisLine);j++){
  34.             temp[j]=thisLine[j];
  35.         }
  36.         printf("%s",thisLine);
  37.         printf("\n");
  38.         start--;
  39.     }
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment