Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b;
- int suma =0;
- cin>>a>>b;
- if(b == 1) {
- cout << a / 100 << endl;
- }
- else if(b == 2) {
- cout << (a / 10) % 10 << endl;
- }
- else if(b == 3) {
- cout <<a % 10 << endl;
- }
- else {
- for(int i =1;i<=b-3;i++){
- int posledna_cifra = a%10;
- int vtora_cifra = (a/10)%10;
- int prva_cifra = a/100;
- suma=posledna_cifra+vtora_cifra+prva_cifra;
- int c=suma%10;
- a*=10;
- a+=c;
- a%=1000;
- }
- cout<<a%10<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement