Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- //La posicion determina el divisor
- int separa( int num,int pos){
- int p=pow(10,pos);
- num=(num /p)%10;
- return num;
- }
- int main (){
- int num,pos;
- while (true){//Bucle continuo para test de la funcion separa
- cout<<" numero ";cin>>num;
- // if (num==0){break;}//Con 0 se sale
- cout<<" posicion ";cin>>pos;
- // cout <<separa (num*10,pos)<<endl;//Para empezar desde 1
- cout <<separa (num,pos)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement