scanf(\"%d\",r)应该修改为scanf(\"%d\",&r)。
另外main函数如果写成int main(),函数末尾应该写上
return 0;
system(\"pause\")这种做法是DOS下的一种做法,Windows下不宜这样做。