Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int primetest(int n)
  7. {
  8. int odb=0,i;
  9.  
  10. for(i=2;i<n;i++)
  11. {
  12. if(n%i==0) odb++;
  13. }
  14. return odb;
  15. }
  16.  
  17. int main()
  18. {
  19. int i,j,db,prime=0;
  20. char t[1000];
  21.  
  22. while(scanf("%s",t)!=EOF)
  23. {
  24.  
  25.  
  26.  
  27. for(i=0;i<strlen(t);i++)
  28. {
  29. prime = 0;
  30. db=1;
  31.  
  32. if(isalpha(t[i])!=0)
  33. {
  34. for(j=i+1;j<strlen(t);j++)
  35. {
  36. if(t[i]==t[j] && isalpha(t[i])!=0)
  37. {
  38. db++;
  39. t[j]='5';
  40.  
  41. }
  42.  
  43. //printf("%s\n",t);
  44.  
  45. }
  46.  
  47. //printf("\n%c db: %d\n",t[i],db);
  48. if(db==1)
  49. {
  50. prime=-1;
  51. break;
  52. }
  53. else{
  54. //if(t[i]=='\n' || t[i]=='\0')
  55. //{
  56. prime=primetest(db);
  57. //printf("**%d**\n",prime);
  58. if(prime!=0)
  59. {
  60. prime=-1;
  61. //printf("nemprim %d\n **%s**\n ",db,t);
  62. break;
  63. }
  64. //}
  65. } //t[i]='*';
  66. }
  67. }
  68. if(prime==-1) printf("NO\n");
  69. else printf("YES\n",prime);
  70. }
  71.  
  72.  
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement