Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <math.h>
- //Niestety program ma problem z obliczaniem ilosci cyfr w liczbach takich jak 1000, 100000 i innych potęgach liczby 10. Nie udalo mi sie tego naprawic.
- using namespace std;
- int a;
- int LICZBA_CYFR(int x){
- int y=1;
- double liczba;
- while(true){
- if(x>=pow(10,y-1)&&x<pow(10,y)){
- return y;
- break;
- }
- else{
- y++;
- }
- }
- }
- int main()
- {
- cout << "Podaj liczbe, aby sprawdzic ile ma cyfr" << endl;
- cin>>a;
- if(a<0){
- a=abs(a);
- cout<<LICZBA_CYFR(a);
- }
- else if(a==0){
- cout<<"0 to jedna cyfra :)";
- }
- else{
- cout<<LICZBA_CYFR(a);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement