Sponsored Content
Full Discussion: Unique Number Identifying
Top Forums Programming Unique Number Identifying Post 302910223 by Gautham on Wednesday 23rd of July 2014 06:16:36 AM
Old 07-23-2014
Unique Number Identifying

I'm trying to solve the below problem for a number:

Enter a number and if it has all unique digits print unique number else non-unique number.
Eg:
Code:
Input=123; Output=unique number
Input=112; Output=Non-unique number

The thing i tried is splitting the number into digits by using % operator and storing it in a array and i'm facing problems while using 2 for loops to traverse the array elements and compared with each other.

Code:
for ( i=0; i<=array_length; i++){
 for( j=i+1; j<=array_length; j++){
  if ( a[i] == a[j] ){
   printf("unique");
  }
 else{
   printf("Non-unique");
  }

I know that i'm wrong, can someone help with any idea to solve.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Directory Inode Number Not Unique

Hi, I know that inode for each file is unique, but is it the for the directory? So far I found different directories has the same inode nubmer when you do ls -i, could some one explain why? Thanks a lot. (9 Replies)
Discussion started by: nj302
9 Replies

2. UNIX for Dummies Questions & Answers

identifying duplicates line & reporting their line number

I need to find to find duplicate lines in a document and then print the line numbers of the duplicates The files contain multiple lines with about 100 numbers on each line I need something that will output the line numbers where duplicates were found ie 1=5=7, 2=34=76 Any suggestions would be... (5 Replies)
Discussion started by: stresslog
5 Replies

3. Shell Programming and Scripting

unique number for a date

Hello, In korn-shell, how can I do to have an unique number for a date done. I want to use it to have the number of days between two dates. Thanks in advance. (4 Replies)
Discussion started by: madmat
4 Replies

4. Shell Programming and Scripting

Identifying the column number

I'd like to be able to identify in which column a string occurs. So far I know that I can tell how many columns there are and how to return a specific column: $ sar -r | grep 'kbswpcad' | awk 'NF = 9 { print $NF }' %swpused I've even managed to get the columns to output to an array but I... (2 Replies)
Discussion started by: pondlife
2 Replies

5. Shell Programming and Scripting

display unique number

Hi, how i can display all the unique number from my random number script below; #!/usr/bin/perl use strict; my @alphanum = ( 'A' .. 'Z', 'a' .. 'z', 0 .. 9); my $random = join('', map($alphanum,(1..5))); print "$random\n"; Thank You. (1 Reply)
Discussion started by: malaysoul
1 Replies

6. Shell Programming and Scripting

Need to find Unique not used Number

Wrote a script to create a hidden account in OS X. It works perfect but I need to check if the UID is already in use before I tried to create the account. dscl . list /Users UniqueID | awk '{print $2}' | while read UIDS do if ; then echo "UID Is Already in USE" i=`expr "$2" - 1` echo... (4 Replies)
Discussion started by: elbombillo
4 Replies

7. Shell Programming and Scripting

minimum number of unique key

input a 1 a 2 a -1 b 1 b 2 b 3 output a -1 b 1 Thanx ---------- Post updated at 09:42 PM ---------- Previous update was at 09:10 PM ---------- Ok I managed it (7 Replies)
Discussion started by: repinementer
7 Replies

8. Shell Programming and Scripting

Finding the number of unique words in a file

find the number of unique words in a file using sort com- mand. (7 Replies)
Discussion started by: abhikamune
7 Replies

9. Shell Programming and Scripting

Concatenate lines with unique string AND number

In Bash using AWK or sed I need to convert the following file: ... numitem_tab0 =<p>1 KEYWORD</p><p>2 KEYWORD</p><p>3 KEYWORD</p><p>4 KEYWORD</p><p>5 KEYWORD</p>...<p>25 KEYWORD</p> subitem_tab0 =<p></p><p></p> ... numitem_tab6 =<p>1 KEYWORD</p><p>2 KEYWORD</p><p>3 KEYWORD</p><p>4 KEYWORD</p>... (2 Replies)
Discussion started by: pioavi
2 Replies

10. Shell Programming and Scripting

Identifying dupes within a database and creating unique sub-sets

Hello, I have a database of name variants with the following structure: variant=variant=variant The number of variants can be as many as thirty to forty. Since the database is quite large (at present around 60,000 lines) duplicate sets of variants creep in. Thus John=Johann=Jon and... (2 Replies)
Discussion started by: gimley
2 Replies
Tk_GetUid(3TK)						       Tk Library Procedures						    Tk_GetUid(3TK)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_GetUid, Tk_Uid - convert from string to unique identifier SYNOPSIS
#include <tk.h> Tk_Uid Tk_GetUid(string) ARGUMENTS
char *string (in) String for which the corresponding unique identifier is desired. _________________________________________________________________ DESCRIPTION
Tk_GetUid returns the unique identifier corresponding to string. Unique identifiers are similar to atoms in Lisp, and are used in Tk to speed up comparisons and searches. A unique identifier (type Tk_Uid) is a string pointer and may be used anywhere that a variable of type ``char *'' could be used. However, there is guaranteed to be exactly one unique identifier for any given string value. If Tk_GetUid is called twice, once with string a and once with string b, and if a and b have the same string value (strcmp(a, b) == 0), then Tk_GetUid will return exactly the same Tk_Uid value for each call (Tk_GetUid(a) == Tk_GetUid(b)). This means that variables of type Tk_Uid may be com- pared directly (x == y) without having to call strcmp. In addition, the return value from Tk_GetUid will have the same string value as its argument (strcmp(Tk_GetUid(a), a) == 0). KEYWORDS
atom, unique identifier ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTk | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tk is available on http://opensolaris.org. Tk Tk_GetUid(3TK)
All times are GMT -4. The time now is 07:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy