Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7.  
  8. int t;
  9. scanf("%d", &t);
  10.  
  11. for(int i = 0; i < t; i++)
  12. {
  13. char num_string[10001];
  14. scanf("%s", num_string);
  15.  
  16. int num;
  17. num = atoi(num_string);
  18.  
  19. int len = strlen(num_string);
  20. int valid[len];
  21. for(int a = 0; a < len; a++)
  22. {
  23. int curr = num_string[a] - '0';
  24. if(curr == 0)
  25. {
  26. valid[a] = 0;
  27. continue;
  28. }
  29. float num_float = (float)num / (float) curr;
  30. int num_int = num/curr;
  31. if(num_float == num_int)
  32. {
  33. valid[a] = 1;
  34. }
  35. else
  36. {
  37. valid[a] = 0;
  38. }
  39. }
  40.  
  41. int counter = 0;
  42.  
  43. for(int a = 0; a < len; a++)
  44. {
  45. if(valid[a] == 1)
  46. {
  47. printf("%d", num_string[a] - '0');
  48. if(a != len-1)
  49. {
  50. printf(" ");
  51. }
  52. }
  53. else
  54. {
  55. counter++;
  56. }
  57. }
  58. if(counter == len)
  59. {
  60. printf("NONE");
  61. }
  62. puts("");
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement