Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am trying to find out how to come up with a x character string that can be made up of either numbers or letters to test a theory.
For example in a one character string, there are 36 possibilities:
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0
This is easy to figure out, but how to I find out how many possibilities there are for a string that is x characters in length?
It's just AN, where A is the number of characters in your alphabet (i.e. 36) and N is the number of characters in your output string.
If you can't use a character more than once, then it is A! / (A-N)! where ! is the factorial operator.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to reverse the order of the words (not the characters) in a specific string with constant extra space in linear time?
First, reverse the whole string (by swapping the first and the last character, towards the middle, etc). This should be enough of a hint to get you started. If not, read on:
Then reverse the order of the characters in each word. Now the characters in each word are in the original order (they were reversed twice overall), but the words are in reverse order (the first word is now at the end, etc.)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
total+=!used[str[i]-'a'];
used[str[i]-'a']=1;
It is the condition for checking the characters and saving the value in the variable total.
The total variable will contain the number of unique characters in the array str.
This happens because you increment the count(total+=!used[str[i]-'a']) only if you haven't already marked the character as visited. If you incremented it, you mark it as such in the next line (used[str[i]-'a']=1) so that you wont count it again.
The notation str[i]-'a' is used to shift the ascii values of the characters from 0 to 25 (instead of 97 to 122) so that you can spare some space in the array.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have tried to sort the numbers using dictionary sort with converting them to strings.But I don't know how to sort numbers using dictionary sort without converting them to strings
Find the largest power of 10 (the number of digits of your biggest number)
Write your compare function so it does a comparison between
a * 10 ^ (max_digits - a_digits) and b * 10 ^ (max_digits - b_digits)
Apply any sort algorithm you wish with this comparison function.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
#include<stdio.h>
#include<conio.h>
void main()
{
printf("%d","");//printing output
getch();
}
The output is 173 .I am not getting why the output is 173.
First, you're trying to print a string as decimal integer, which means the decimal you try to print is going to be the pointer to the string (actually a pointer to the array of characters) and not the string itself. To use an individual character use single-quotes, not double-quotes.
To accomplish what you're actually trying to do, do this:
printf("%d", ' ');
Note there is an actual space between the two single-quotes.
The result will be 32, which is the decimal value for the ASCII Space character.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I can't ask my lecturer at this moment seeing as where i am it's late at night and on the weekend.
this is the question:
"Write a program that inputs a string from the keyboard and determines the length of the string. Print the string using twice the length as the width."
The bolded bit is the part i don't understand.
He means to print with padding
e.g.
Hello <-- not padded
Hello <-- padded in 10-char field, right justified