为了学习(或重新学习)C,有哪些好的项目可以解决?理想情况下,类似于大学课堂上可能获得的作业.可以在线获得实际分配/项目规范的链接.
注意:它们不一定是C类或类似的任务.只是那种能够很好地实现低水平的东西.同时学习其他有趣的东西是奖金!
如果已经在某个地方询问过这个问题,请向我指出.我尝试过的搜索词(课程,作业......!)不像我们想象的那样有助于我的搜索.
我想重新定义Subscript"二叉树坐标"被翻译成"平面阵列坐标":
Unprotect[Subscript];
Subscript[x_, i_, j_] := x[[2 ^ i + j]];
Protect[Subscript];
(* Binomial Tree *)
y = {.1, {.2, .3}} // Flatten;
Subscript[y, 1, 1]
Subscript[y, 1, 1] = .5;
Subscript[y, 1, 1]
Run Code Online (Sandbox Code Playgroud)
我期望得到的是.3, .5.相反,我得到了,Set::write : Tag Subscript in {.1, .2, .3}_1,1 is Protected并没有分配价值.请指教.
我试图将整个文件读入变量而不删除任何字符.我敢肯定这一定很简单.
这不起作用,因为它删除了重复空格,所有标签和换行符:
$ echo 'fred wilma' > somefile; z=$(cat somefile); echo $z
fred wilma
Run Code Online (Sandbox Code Playgroud)
我可以通过简单的赋值看到相同的过滤,如下所示:
$ z='fred wilma'; echo $z
fred wilma
Run Code Online (Sandbox Code Playgroud)
但不是我这样做的时候:
$ echo 'fred wilma'
fred wilma
Run Code Online (Sandbox Code Playgroud)
如何获取bash变量以在分配时停止解析和过滤?
只是希望快速验证这一点.它与我从其他语言的直接经验不同,在这种经验中,必须首先声明数组才能填充值.
这是这个问题的后续问题,最初受到这个问题的启发,但并不完全相同.
这是我的情况.首先我从数据库中提取一些数据,
df <- data.frame(id = c(1:6),
profession = c(1, 5, 4, NA, 0, 5))
df
# id profession
# 1 1
# 2 5
# 3 4
# 4 NA
# 5 0
# 6 5
Run Code Online (Sandbox Code Playgroud)
其次,我提供了一个关键字表,其中包含有关行业代码的人类可读信息,
profession.codes <- data.frame(profession.code = c(1,2,3,4,5),
profession.label = c('Optometrists',
'Accountants', 'Veterinarians',
'Financial analysts', 'Nurses'))
profession.codes
# profession.code profession.label
# 1 Optometrists
# 2 Accountants
# 3 Veterinarians
# 4 Financial analysts
# 5 Nurses
Run Code Online (Sandbox Code Playgroud)
现在,我想profession用我df的标签来覆盖我的变量 …
我正在阅读"Ivor Horton的开始编程Visual C++ 2010",我在第10章 - 标准模板库.我的问题在于地图容器map<Person, string> mapname.这本书向我展示了很多添加元素的方法,比如稍后pair<K, T>使用和使用make_pair()函数,以及mapname.insert(pair).但突然他引入了以下代码中使用的元素添加技术:
int main()
{
std::map<string, int> words
cout << "Enter some text and press Enter followed by Ctrl+Z then Enter to end:"
<< endl << endl;
std::istream_iterator<string> begin(cin);
std::istream_iterator<string> end;
while(being != end) // iterate over words in the stream
//PROBLEM WITH THIS LINE:
words[*begin++]++; // Increment and store a word count
//there are still more but irrelevant to this question)
}
Run Code Online (Sandbox Code Playgroud)
指示的行是我的问题.我明白这words …
我在这里遇到了以下在Eigen Library中分配矩阵的问题
Matrix3f m;
m << 1, 2, 3,
4, 5, 6,
7, 8, 9;
Run Code Online (Sandbox Code Playgroud)
作为无聊(m(0,0) = 1;...等)的一种替代方式。我的问题是,使用第一种方法应注意哪些注意事项?因为我知道任何简化都是有代价的。
我在Haskell中有这个代码.
import Data.List
main = do
putStrLn $ "\nVerify if Exists in a String"
let wordlist = ["monad", "monoid", "Galois", "ghc", "SPJ"]
let tweet = "This is an example tweet talking about SPJ interviewing with Galois"
print $ map (flip isInfixOf tweet) wordlist
Run Code Online (Sandbox Code Playgroud)
没有let,我有这个错误信息:10_things.hs:16:14: parse error on input ‘=’.
这是另一个工作正常的代码.
import Data.List
wordlist = ["monad", "monoid", "Galois", "ghc", "SPJ"]
tweet = "This is an example tweet talking about SPJ interviewing with Galois"
main = do
putStrLn …Run Code Online (Sandbox Code Playgroud) while(bo!=10){
x = tryCatch(getURLContent(Site, verbose = F, curl = handle),
error = function(e) {
cat("ERROR1: ", e$message, "\n")
Sys.sleep(1)
print("reconntecting...")
bo <- bo+1
print(bo)
})
print(bo)
if(bo==0) bo=10
}
Run Code Online (Sandbox Code Playgroud)
我想尝试在连接失败后重新连接每秒.但是bo值的新赋值是无效的.我怎样才能做到这一点?或者,如果您知道如何使用RCurl选项重新连接(我真的没有找到任何东西),那将是惊人的.
感谢每一位帮助
如果我有一个当前为空的字符串
String s = "";
Run Code Online (Sandbox Code Playgroud)
并重新分配
s = "";
Run Code Online (Sandbox Code Playgroud)
这不好我不这样做吗?
if(!s.isEmpty()){
s = "";
}
Run Code Online (Sandbox Code Playgroud)
或者编译器会接收它并为我优化?