Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:05:17+00:00 2026-06-12T04:05:17+00:00

I am new to C++ development and I was hoping someone could help me

  • 0

I am new to C++ development and I was hoping someone could help me with something I have been trying to do.

Say for example I want a function that will, given an integer input, return the number of distinct digits it contains.

So for example, if I have three integers:

int a = 19876;
int b = 25644;
int c = 4444;

If I pass ‘a’ into the function, I would expect the number 5 to be returned.
If ‘b’ was passed into the function, I would expect ‘4’ to be returned,
If ‘c’ was passed into the function, then 1 would be returned, as they are the number of distinct numbers.

Could someone please illustrate how I could achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:05:18+00:00Added an answer on June 12, 2026 at 4:05 am

    You mean you want to find the number of different decimal digit in the integer?

    int distinct_digits(int value) {
        std::ostringstream out;
        out << value;
        std::string digits = out.str();
        std::sort(digits.begin(), digits.end());
        return std::unique(digits.begin(), digits.end()) - digits.begin();
    }
    

    (not compiled or tested but the basic idea should work)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Eclipse/Android development so I'm hoping this is something basic that I'm
Hi I am fairly new to Android development and am hoping someone can help
I am relatively new to web development, and I was hoping I could get
Thanks for viewing my question. I'm new to web development and was hoping someone
My development team has run into a design issue. I'm hoping someone can help
I am new iOS development but I know android at eclipse. For example I
I have recently installed the new Azure development tools for Visual Studio 2010 service
I have been troubleshooting a very odd issue in my local development rails setup
I've been doing development in TWIG lately. It is an html templating language that
I'm fairly new to real world MVC / .NET development (i've been studying MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.