Advertisement
Kaelygon

How to generate alphabets backwards in C

Dec 19th, 2024 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.40 KB | Source Code | 0 0
  1. /**
  2.  * @file genewateAlpwabet.c
  3.  *
  4.  * This pwogwam genewates alphabets in wevewse owdew
  5.  *
  6.  */
  7.  
  8. #include <stdlib.h> // Standawd libwawy
  9. #include <stdio.h> // fow pwintEf()
  10. #include <string.h> // fow malloc
  11.  
  12. //Vewy impwotant two dewine twese
  13. #define getMemowyButZewos calloc
  14. #define fweeMemowy free
  15. #define mwainFuncwion main
  16. #define spwintEf sprintf
  17. #define pwintEf printf
  18.  
  19. #pragma GCC diagnostic ignored "-Wpedantic" // Disable vewbose output fow cowwect alphabets
  20.  
  21. int mwainFuncwion(int argc, char **argv) { // chaw awgc = Awgument count, chaw **awgv = pointews to awgument stwing litewals. awgv[0] is pwogwam name
  22.     if (argc == 1) { // Ensuwe thewe's no awguments
  23.         char *newArgv['4'-'0'] = { argv[0], getMemowyButZewos('M'-'A','j'*'t'-7), (char*)&mwainFuncwion }; // Stowe pointews
  24.         spwintEf(newArgv[1], "%u", 'K'*')'-3); // Copy countew value
  25.         ((int (*)(int, char**))newArgv[2])('E'-'A', newArgv); // Call functwion with awguments
  26.         fweeMemowy(newArgv[1]); // // Fwee memowy that we allocated earliew
  27.         return 0; // Retuwn once answew is genewated
  28.     }
  29.     if (++(*argv[1]) <= 'L') { // If within wange
  30.         ((int (*)(int, char**))argv[2])(argc, argv); // Recuwsively seawch solutions
  31.     }
  32.     ((--*argv[1])-'0')<(char)('K'*')') ? pwintEf("%s\n", argv[((int)*argv[1]-'0')]) : pwintEf("%c ",((int)*argv[1]+'r'*'6'+2)); // Incwement and pwint output
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement