0

Write a code in which input is name of person and output is a random number between 0 to 9.

The output number should not be in any guessable pattern. it should be fully random. also if two person have same name, their output should not equal, it should be also random.

26th Jan 2018, 5:08 AM
Kundan
Kundan - avatar
14 Answers
+ 8
The question could be more sensible if you ask about an encryption/decryption system in which a string of character is manipulated with a key. Simplest example: #include <iostream> #include <string> using std::cout; using std::string; using std::cin; int main() { /*----------------------------*/ string key = "Kundan0123456789abcdefghijklmnopqrstuvwxyz$
quot;; string str = ""; /*----------------------------*/ do { cout << "Your string is (Max 45 char): "; std::getline(cin, str); } while (str.length() > key.length());// Max acceptable input is 45 character // Encryption phase for (auto i = 0; i < str.length(); ++i) { str.at(i) ^= key.at(i); cout << str.at(i); } cout << std::endl; // Decryption phase for (auto i = 0; i < str.length(); ++i) { str.at(i) ^= key.at(i); cout << str.at(i); } cout << std::endl; } LiveLink: [http://cpp.sh/9vqhj] SlLink: [https://code.sololearn.com/cd7J0U0BN859] Ref_1:[https://en.wikipedia.org/wiki/XOR_cipher] Ref_2: [https://www.cprogramming.com/tutorial/xor.html]
26th Jan 2018, 7:37 AM
Babak
Babak - avatar
+ 8
@person's name your replay text ...
26th Jan 2018, 1:51 PM
Babak
Babak - avatar
+ 6
so how does the input name influence the output?if we're generating totally random numbers what do we need to receive a name input for?
26th Jan 2018, 5:24 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 6
@Kundan Some ideas come to you along the the way of learning and even when you got experienced. The important thing to consider is keep those idea in your back pocket no matter how wrong or silly they might appear to be at the moment, for other learners like me. Every responsible learner/teacher in this "cluttered mini forum" does something useful to help their peers. Some people is more responsible than others. Some people " GO DEEP" in the process rather than accepting the things as they are. That's how we grow. If you don't know much about the area that you love that doesn't mean you can't face with some fairly complicated stuff and get stuck. That's true, new things make people uncomfortable but so what? You learn, you gain, you put more effort on it and then come back and break the barrier. BTW, I attached some easy to understand reference at the end of my little example. If you had any question about that, please ask.
26th Jan 2018, 3:56 PM
Babak
Babak - avatar
+ 6
I wish you great moments here and above that in your personal life, dear Kundan.
26th Jan 2018, 4:26 PM
Babak
Babak - avatar
+ 1
can anybody tell how can I reply a specific person here?
26th Jan 2018, 1:36 PM
Kundan
Kundan - avatar
+ 1
@Babak Sheykhan Thanks. you are right. and I know I need the things that you given. but as I say that I only know a b c d. not much. so I need some time to achieve the level after that I can understand your examples. till now I only completed the basics of C++ and loops. in last thanks to all for his support.
26th Jan 2018, 4:15 PM
Kundan
Kundan - avatar
0
I am not a programmer, start just learning codes. learnt some a b c d. I have posted this question for got a badge. Mr Ace tried well, he first ask what I tried. it was a genuine question. Mr Babao suggest for encryption in question. but I not learnt much to ask such. and the reply is beyond my knowledge. I was expecting for such code which can be understand by me.
26th Jan 2018, 2:59 PM
Kundan
Kundan - avatar
0
@JPM7 may be u define on name. because any function need a base, without base you can't get anything. I don't have any purpose for randomness, only want to play with simple codes. as much simple you can think as much higher you can hit. I only know that computer know only 0 and 1.
26th Jan 2018, 3:31 PM
Kundan
Kundan - avatar
0
@JMP7 Thankyou. but I think, if human not feel thirsty, he never drink water.
26th Jan 2018, 3:37 PM
Kundan
Kundan - avatar
0
@Ace actually I am new here. this was my 1st question and only for the purpose to understand the process of discussion which give me enough output. I seen that at any astrologer a circle having digits on that. when any person goes to him he ask his name and tern the circle. and give decisions on outcome. I ask this question keeping that thing in mind. nothing else.
26th Jan 2018, 3:46 PM
Kundan
Kundan - avatar