Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define SIZE 10
  5. #define LEN 30
  6. #define LETTER 27
  7. #define ENGLISH 26
  8.  
  9. void myFgets(char str [][LEN] , int len);
  10. int allLetters(char words[][LEN], int place, char letters[], int counter[]);
  11.  
  12.  
  13. int main()
  14. {
  15. char words [SIZE][LEN] = {0};
  16.  
  17. int i = 0;
  18. int exit = 0;
  19. int len = 0;
  20. int c[1] = {0};
  21.  
  22. //all the letters in English language
  23. char letters[LETTER] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0}; //letters array
  24.  
  25. printf("Enter up to 10 words, try to make a pangram:\n");
  26.  
  27. for(i = 0; i < SIZE && exit != 1; i++)
  28. {
  29. myFgets(words , SIZE);
  30.  
  31. exit = allLetters(words ,i ,letters, c);
  32.  
  33. }
  34.  
  35. if(exit == 1)
  36. {
  37. printf("It's a pangram?\nYES!!");
  38. }
  39. else
  40. {
  41. printf("It's a pangram?\nNO!!");
  42. }
  43.  
  44. return 0;
  45. }
  46.  
  47. /*
  48. The function checking a word to see if it has all the letters.
  49. Input: the string and the len
  50. Output: None
  51. */
  52. int allLetters(char words[][LEN], int place, char letters[], int c[])
  53. {
  54.  
  55. int i = 0; //vars
  56. int j = 0;
  57. int exit = 0;
  58.  
  59. for(i = 0; i < strlen(words[place]); i++)
  60. {
  61. for(j = 0; j < LETTER ; j++)
  62. {
  63. if(words[place][i] == letters[j])
  64. {
  65. letters[j] = 'A';
  66. c[0] = c[0] + 1;
  67.  
  68. }
  69.  
  70. }
  71. }
  72.  
  73. if(c[0] == ENGLISH)
  74. {
  75. exit = 1;
  76. }
  77.  
  78. return exit;
  79. }
  80. /*
  81. get the words into the string and delete the spaces
  82. Input: the string and the len
  83. Output: None
  84. */
  85. void myFgets(char str [][LEN] , int len )
  86. {
  87.  
  88. int i = 0;
  89. for(i=0; i<len; i++)
  90. {
  91. fgets(str[i] , LEN , stdin);
  92. str[i][strcspn(str[i],"\n")]=0;
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement