我正在尝试使用数组来修正一个程序,它可以获得0到24之间的随机数,但它们只能出现一次.我知道如何生成随机数,我只是坚持如何检查数字中是否已存在数字.我尝试生成一个新的rand()%25并将其与数组中的占位符进行比较,如果它不存在则将新的随机数放在那里,但它不起作用.
void MultiU (){
int size = 5;
int array[5];
srand(time(0));
for (int index = 0; index < size; index++){
exists[index] = rand() %25;
}
}
Run Code Online (Sandbox Code Playgroud)
我是使用数组和rand()进行编程的新手.我希望有人可以指导我朝着正确的方向前进.
我是Python的新手,我正在编写下面的代码.
fileName = input("Enter the file name: ")
InputFile = open(fileName, 'r')
text=InputFile.readable()
sentences = text.count('.') + text.count('?') + \
text.count(':') + text.count(';') + \
text.count('!')
Run Code Online (Sandbox Code Playgroud)
由于下面的错误,我无法通过计数功能.我做了一些研究并尝试导入一些库,但这没有用.有人能引导我朝正确的方向发展吗?我感觉很失落.
text.count(':') + text.count(';') + \
AttributeError: 'bool' object has no attribute 'count'
Run Code Online (Sandbox Code Playgroud)