Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int ile;
  7. float a,b;
  8.  
  9. unsigned long long int potega(int podstawa, int wykladnik)
  10. {
  11. if(wykladnik==0) return 1;
  12. else return potega(podstawa,wykladnik-1)*podstawa;
  13. }
  14.  
  15. int main()
  16. {
  17. cin >> ile;
  18. for(int i=0; i<ile; i++)
  19. {
  20. cin>>a>>b;
  21. cout<<potega(a,b)<<endl;
  22.  
  23. }
  24. return 0;
  25. }
  26.  
  27.  
  28.  
  29. =====================================================
  30.  
  31.  
  32.  
  33. #include <iostream>
  34.  
  35. using namespace std;
  36.  
  37. int ile;
  38. float a,b;
  39.  
  40. long long int potega(int podstawa, int wykladnik)
  41. {
  42. long long int wynik = 1;
  43.  
  44. for (int i = 0; i<wykladnik; i++)
  45. wynik*=podstawa;
  46.  
  47. return wynik;
  48. }
  49.  
  50. int main()
  51. {
  52. cin >> ile;
  53. for(int i=0; i<ile; i++)
  54. {
  55. cin>>a>>b;
  56. cout<<(potega(a,b))%10<<endl;
  57. }
  58. return 0;
  59. }
  60.  
  61.  
  62.  
  63. =============================================================
  64.  
  65.  
  66. #include <iostream>
  67. #include <math.h>
  68.  
  69. using namespace std;
  70.  
  71. int ile;
  72. float a,b;
  73.  
  74.  
  75. int main()
  76. {
  77. cin >> ile;
  78.  
  79. for(int i=0; i<ile; i++)
  80. {
  81. cin>>a>>b;
  82. double c;
  83. c=pow(a,b);
  84. cout<<(int)c%10<<endl;
  85.  
  86. }
  87. return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement