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

  • Home
  • SEARCH
  • 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 7496215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:32:01+00:00 2026-05-29T18:32:01+00:00

I am writing a program which has an output requirement for the number printed

  • 0

I am writing a program which has an output requirement for the number printed to not have a repeated integer in it

i.e. it would not print 122, 161, 998, etc
but it would print any other number such as 123, 345, 742..etc

how do i go about doing this? thanks!

  • 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-05-29T18:32:05+00:00Added an answer on May 29, 2026 at 6:32 pm

    A C-language compatible solution would be to convert the number to a string and keep a frequency count of the digits and return true if there are duplicates, e.g.:

    int has_duplicate_digit(char * s) {
      char digit_count[10] = {0,0,0,0,0,0,0,0,0,0};
      for (int i=0; i<strlen(s); i++) {
        if ('0' <= s[i] && s[i] <= '9') {
          if (++digit_count[s[i]-'0'] > 1) return 1; // true
        }
      }
      return 0; // false
    }
    

    [Edit] You can also save a few bytes (and possibly some time) by using a bitset instead of an int array. For example:

    #include <stdint.h>
    int has_duplicate_digit2(char * s) {
      uint16_t digit_count = 0;
      for (int i=0; i<strlen(s); i++) {
        if ('0' <= s[i] && s[i] <= '9') {
          uint16_t bit = 1 << (s[i] - '0');
          if (digit_count & bit) return 1; // true
          digit_count |= bit;
        }
      }
      return 0; // false
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a program which has two panes (via CSplitter ), however I
I'm writing a program which has both an ASP.NET configuration system and a Silverlight
I'm writing a program that has an NSView embedded in an NSScrollView which user
Right now I am writing a simulation program which output is formatted according to
I have a program which writes its output using ofstream. Everything works perfectly fine
I am writing a program which has 8 threads. I am implementing a barrier
I'm writing a program to do a search and export the output. I have
I'm writing a program which has two main phases: determining the region of interest,
I'm writing a program that uses an Event class, which has in it an
I have a little program, let's call it program by simplicity which has normal

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.