对于我的情况,我必须检查2个字符串是否相同.我得到了万阿英,蒋达清,就是不管我投入,我得到一个真正的价值,无论是我插嘴说.
bool Dictionary::checkIfWordExists(string input){
for(int counter=0;counter<234;counter++){
if(input.compare(getWordFromDictionary(counter))){
return true;
}
}
return false;}
Run Code Online (Sandbox Code Playgroud)
出于测试目的,我使用这样的do循环来输入要测试的东西,与我加载的dictionary.txt文件相比较.
do{
cout<<"enter something you sexy beast"<<endl;
string test;
cin>>test;
if(loadedDictionary.checkIfWordExists(test)){
cout<<"yes"<<endl;
}else{
cout<<"no"<<endl;
}
}while(true);
Run Code Online (Sandbox Code Playgroud) 首先,我对编码很新,所以如果这是一个愚蠢的问题请耐心等待.我不知道如何将int array [10]之类的soemthing转换为单个NSString.我一直在寻找解决方案,但到目前为止,我所看到的只是从数组转换为字符串数组.
我试过的第一件事就是
NSString *String=[NSString stringWithFormat @"%i",array];
Run Code Online (Sandbox Code Playgroud)
但问题是,我知道我可以做类似的事情
NSString *String[NSString stringWithFormat @"%i%i%i...",array[0],array[1],array[2],.....];
Run Code Online (Sandbox Code Playgroud)
但是我试图避免这种情况,因为我将对10个以上的变量进行此操作,并且我将使用单独命名的变量进行相当多的操作
对于我的编程语言课程,我应该在 Scheme 中编写一个函数来反转列表,而不使用预制的反转函数。到目前为止我得到的是
(define (reverseList lst)
(COND
((NULL? lst) '())
(ELSE (CONS (reverseList(CDR lst)) (CAR lst)))
))
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,如果我输入一个列表,可以说它(a b c)给了我(((() . c) . b) . a).
我该如何获得一个没有多组括号和 的干净列表.?