Sorry to ask.How to display random alphabet in table ?? Like 4 random alphabet (without repeat) table with row 2 column 2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Sorry to ask.How to display random alphabet in table ?? Like 4 random alphabet (without repeat) table with row 2 column 2

The table have border

17th Dec 2021, 1:26 PM
Shannen
8 Answers
+ 4
If I understood your question Shannen then this is the solution: https://code.sololearn.com/cPz4KPNDlsgj/?ref=app
17th Dec 2021, 4:18 PM
JaScript
JaScript - avatar
+ 2
You mean each cell contains exactly one character? i think the tricky part is the border printing part ...
17th Dec 2021, 1:35 PM
Ipang
+ 2
Yes
17th Dec 2021, 1:36 PM
Shannen
+ 2
Thanks ☺️
17th Dec 2021, 4:26 PM
Shannen
+ 1
About the 4 random characters, since you'd be using char array ... Generate random value between 33 ~ 128 (exclusive). Check whether such value exist in the char array by using strchr() fromX:Ft <cstring>. If such character already exiat, generate another one until all 4 slots are filled with unique values. Can't suggest anything on the border printing part though ...
17th Dec 2021, 1:51 PM
Ipang
+ 1
Start with "abcd"; For i from 5 to 25 geneate a random number from 0 to i If it's less than 5 substitute that character with the i-th letter in the alphabet E.g.: abcd 'e' : rand from 0 to 5 -> 3 abce 'f' : rand from 0 to 6 -> 1 abfe 'g' : rand from 0 to 7 -> 5 abfe ... 'z' : rand from 0 to 25 ->3 jtfz For printing the grid you could use unicode box drowning characters, or just plain old ASCII E.g.: === ___ +--- ### || a | a | a # a
17th Dec 2021, 2:43 PM
Angelo
Angelo - avatar
+ 1
JaScript Function and array is so difficult for me to understand,u help me a lot to solve the problem...Thanks a lot
17th Dec 2021, 5:43 PM
Shannen
+ 1
👍 thanks
17th Dec 2021, 6:21 PM
Shannen