C++ 编程出现错误,求大神指导
#include "stdafx.h"int t;
int limit,SumCube;
scanf("%d",limit);
for (limit=0;t=limit+1;t<101)
if(t=limit-1&&t<0)
return 0;
else SumCube+=t*t*t;
printf("%d\n",SumCube);
要求:输入1到limit(limit小于100)的所有正整数的立方和。
运行程序后,错误如下:
'scanf' : missing storage-class or type specifiers
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(8) : error C2078: too many initializers
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2143: syntax error : missing ';' before 'for'
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2143: syntax error : missing ')' before ';'
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2501: 't' : missing storage-class or type specifiers
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2086: 't' : redefinition
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2143: syntax error : missing ';' before '<'
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2501: 't' : missing storage-class or type specifiers
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2086: 't' : redefinition
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2143: syntax error : missing ';' before '<'
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(9) : error C2059: syntax error : ')'
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(12) : error C2143: syntax error : missing ';' before 'else'
C:\Users\Administrator\Desktop\实验4\啦啦\StdAfx.cpp(13) : error C2501: 'printf' : missing storage-class or type specifi
: too many initializers
虽然程序运行后显示的错误都是符号的问题,但我认为应该还是语句本质出了问题,求大神指教!
我定义的t是limit+1,然后立方和一项一项加,实在不知道哪出错了!