Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 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. for(i=0;i<strlen(t);i++)
  27. {
  28. prime = 0;
  29. db=1;
  30.  
  31.  
  32. for(j=i+1;j<strlen(t);j++)
  33. {
  34. if(t[i]==t[j] && isalpha(t[i]))
  35. {
  36. db++;
  37. t[j]='5';
  38.  
  39. }
  40.  
  41. printf("%s\n",t);
  42.  
  43. }
  44.  
  45. printf("%c db: %d\n",t[i],db);
  46. if(db==1)
  47. {
  48. prime=-1;
  49. break;
  50. }
  51. else{
  52. if(t[i]=='\n' || t[i]=='\0')
  53. {
  54. prime=primetest(db);
  55. if(prime!=0)
  56. {
  57. prime=-1;
  58. printf("nemprim %d\n **%s**\n ",db,t);
  59. break;
  60. }
  61. }
  62. } //t[i]='*';
  63. }
  64. if(prime==-1) printf("NO\n");
  65. else printf("YES %d\n",prime);
  66. }
  67.  
  68.  
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement