declare @iCount int
select @iSum = 0
select @iCount = 1
while @iCount <= 100
begin
select @iSum = @iSum + @iCount
select @iCount = @iCount + 1
end
mian(){
int n,sum=0
for(n=0n<100n++)
{
if(!n%2){
sum+=n
}
}
}
代码如下:
DECLARE @i INT,@sum INTSET @i=1
SET @sum=0
WHILE @i<=100
BEGIN
SET @sum=@sum+@i
SET @i=@i+1
END
PRINT @sum
运行结果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)