Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include <cstdlib>
- using namespace std;
- int main() {
- int n, c, d, g=0, p;
- double e, f;
- int z, x;
- cout << "Program sumujacy trzecia potege kazdej z cyfr z ktorych sklada sie wprowadzona liczba 'n'." << endl;
- cout << "###########################################################################################" << endl;
- cout << "Podaj liczbe 'n': ";
- cin >> n;
- int n2 = n;
- int len = 1;
- if (n2 > 0) {
- for (len = 0; n2 > 0; len++) {
- n2 = n2 / 10;
- }
- }
- for (int i = 1; i < len+1; i = i++)
- {
- e = (pow(10, i)) / 10;
- z = (int) e;
- d = n / z;
- c = d % 10;
- f = pow(c, 3);
- x = (int) f ;
- if (e == 0)
- break;
- cout << "Potega " << i << " cyfry: " << x << endl;
- g = g + x;
- }
- cout << "Suma szescianow cyfr liczby: "<< g << endl;
- cin >> p;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement