fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. #include <sstream>
  5. using namespace std;
  6. string wyraz;
  7. int x,dlugosc,a,testy;
  8. float y;
  9. double pesel;
  10. int suma=0;
  11. int *tablica;
  12. int main()
  13. {
  14. cin>>testy;
  15. for(int k=1; k<=testy; k++)
  16. {
  17. cin>>pesel;
  18. if(pesel>=0)
  19. {
  20. dlugosc=11;
  21. tablica=new int[11];
  22.  
  23. for(int j=1; j<=dlugosc; j++)
  24. {
  25. x=pesel/pow(10,dlugosc-j);
  26. tablica[j-1]=x;
  27. y=x*pow(10,dlugosc-j);
  28. pesel=pesel-y;
  29. }
  30. for(int i=0; i<dlugosc; i++)
  31. {
  32. switch(i)
  33. {
  34. case 0:
  35. a=tablica[i]*1;
  36. break;
  37. case 1:
  38. a=tablica[i]*3;
  39. break;
  40. case 2:
  41. a=tablica[i]*7;
  42. break;
  43. case 3:
  44. a=tablica[i]*9;
  45. break;
  46. case 4:
  47. a=tablica[i]*1;
  48. break;
  49. case 5:
  50. a=tablica[i]*3;
  51. break;
  52. case 6:
  53. a=tablica[i]*7;
  54. break;
  55. case 7:
  56. a=tablica[i]*9;
  57. break;
  58. case 8:
  59. a=tablica[i]*1;
  60. break;
  61. case 9:
  62. a=tablica[i]*3;
  63. break;
  64. case 10:
  65. a=tablica[i]*1;
  66. break;
  67. }
  68. suma+=a;
  69.  
  70. }
  71. ostringstream ss;
  72. ss<<suma;
  73. string suma1=ss.str();
  74. int c=suma1.length();
  75.  
  76. if(suma1[c-1]=='0')
  77. {
  78. cout<<"D"<<endl;
  79. }
  80. else cout<<"N"<<endl;
  81. suma=0;
  82. }
  83. else cout<<"N"<<endl;
  84. }
  85. return 0;
  86. }
  87.  
  88.  
Success #stdin #stdout 0s 16072KB
stdin
2
44051401458
12345678901
stdout
D
N