Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// ElimCifRec
- #include <iostream>
- using namespace std;
- int elimcif_iterativ(int n,int c)
- {
- int x,p=1,cifra;
- x=0;
- while(n>0){
- cifra=n%10;
- if(cifra!=c){
- x = x + cifra * p;
- p = p * 10;
- }
- n=n/10;
- }
- return x;
- }
- int elimcif(int n , int c)
- {
- if(n == 0)
- return n;
- else
- if(n % 10 == c)
- return elimcif(n / 10 , c);
- else
- return elimcif(n / 10 , c) * 10 + n % 10;
- }
- int fact(int n)
- {
- if(n==0) return 1;
- return fact(n-1)*n;
- }
- int main(){
- int nr,c;
- cout<<fact(3)<<endl;
- nr=2547222; c=2;
- cout<<elimcif(nr,c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement