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.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define SIZE 10
  5. #define LEN 30
  6. #define ENGLISH 26
  7.  
  8. void myFgets(char str [][LEN] , int len);
  9. int allLetters(char str[][LEN], int placer, char letters[], int counter[]);
  10.  
  11.  
  12. int main()
  13. {
  14. char str [SIZE][LEN] = {0};
  15.  
  16. int i = 0;
  17. int exit = 0;
  18. int len = 0;
  19. int c[1] = {0};
  20.  
  21. //all the letters in English language
  22. char letters[ENGLISH+1] = {'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};
  23. printf("Enter up to 10 words and try to make a pangram: \n");
  24.  
  25. for(i = 0; i < SIZE && exit != 1; i++)
  26. {
  27. myFgets(str , SIZE);
  28.  
  29. exit = allLetters(words ,i ,letters, c);
  30.  
  31. }
  32.  
  33. if(exit == 1)
  34. {
  35. printf("It's a pangram?\nYES!!");
  36. }
  37. else
  38. {
  39. printf("It's a pangram?\nNO!!");
  40. }
  41.  
  42. return 0;
  43. }
  44.  
  45. /*
  46. The function checking a word to see if it has all the letters.
  47. Input: the string and the len
  48. Output: None
  49. */
  50. int allLetters(char str[][LEN], int placer, char letters[], int c[])
  51. {
  52.  
  53. int i = 0; //variables
  54. int j = 0;
  55. int exit = 0;
  56.  
  57. for(i = 0; i < strlen(words[placer]); i++)
  58. {
  59. for(j = 0; j < ENGLISH+1 ; j++)
  60. {
  61. if(words[placer][i] == letters[j])
  62. {
  63. letters[j] = 'Z';
  64. c[0] = c[0] + 1;
  65.  
  66. }
  67.  
  68. }
  69. }
  70.  
  71. if(c[0] == ENGLISH)
  72. {
  73. exit = 1;
  74. }
  75.  
  76. return exit;
  77. }
  78. /*
  79. get the words into the string and delete the spaces
  80. Input: the string and the len
  81. Output: None
  82. */
  83. void myFgets(char str [][LEN] , int len )
  84. {
  85.  
  86. int i = 0;
  87.  
  88. fgets(str[i] , LEN , stdin);
  89. str[i][strcspn(str[i],"\n")]=0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement