I am trying to generate different character which lowercase and ten times. But I couldn't. So guys, I would appreciate if you help. Thank you,
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(NULL));
char letters[10];
for (int i = 0; i < 10; i++)
{
letters[i] = 97 + rand() % (122-97);
for (int j = 1; j < i; j++)
{
if (letters[i]==letters[j])
{
letters[i] = 97 + rand() % (122-97);// continue;
}
}
printf("%c\n", letters[i]);
}
}
Aucun commentaire:
Enregistrer un commentaire