Advertisement
Hadix

OSTSIL - Ostania niezerowa cyfra silni

Feb 9th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. // Spojek.cpp : Defines the entry point for the console applicatio
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <iostream>
  4. #include <string>
  5. #include <time.h>
  6.  
  7. using namespace std;
  8.  
  9. void otsil()
  10. {
  11.     char numer[4];
  12.     int r = 0;
  13.     int n;
  14.     int w = 1;
  15.     cin >> n;
  16.     for (int j = 1; j <= n; j++) {
  17.         w *= j;
  18.     }
  19.     while (w % 10 == 0)
  20.     {
  21.         w = w / 10;
  22.     }
  23.     r = w % 10;
  24.     cout << r << endl;
  25. }
  26.  
  27.  
  28. int main()
  29. {
  30.     int t;
  31.     cout << "Wprowadz liczbe testow:" << endl;
  32.     cin >> t;
  33.     for (int i = 0; i < t; i++)
  34.     {
  35.         otsil();
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement