主题:[讨论]请高手帮我分析这个程序为何提示是输入带副作用的符号
chenminxia
[专家分:0] 发布于 2010-11-22 14:02:00
#include<stdio.h>
int main (void)
{
int readnum;
int numbers[50];
printf("how many numbers would you like ?");
scanf("%d",&readnum);
if(readnum>=50)
readnum=50;
print("\nenter your numbers: \n");
for(int i=0;i<readnum;i++)
scanf("%d",&numbers[i]);
printf("reversed ary");
for(int i=readnum-1,numprited=0;i>=0;i--)
{
printf("%3d",numbers[i]);
if(numprinted<9)
numprinted++;
else
numprinted=0;
}
return 0;
}
最后更新于:2010-11-21 23:09:00
回复列表 (共3个回复)
沙发
lukexc [专家分:50] 发布于 2010-11-22 19:46:00
[code=c]
楼主
#include<stdio.h>
int main (void)
{
int readnum;
int numbers[50];
printf("how many numbers would you like ?\n");
scanf("%d",&readnum);
if(readnum>=50)
readnum=50;
print("\nenter your numbers: \n");//printf书写错误
for(int i=0;i<readnum;i++)
scanf("%d",&numbers[i]);
printf("reversed ary");
for(int i=readnum-1,numprited=0;i>=0;i--)//numprited没有声明而且和后文不相同
{
printf("%3d",numbers[i]);
if(numprinted<9)
numprinted++;
else
numprinted=0;
}
return 0;
}[/code]
板凳
chenminxia [专家分:0] 发布于 2010-11-22 22:54:00
[em2]谢谢啊 不过改过来后还是无法运行
visual stdio 2008提示
1>e:\vs2008\c\c语言\c语言\循环.c(16) : warning C4552: “>=”: 运算符不起任何作用;应输入带副作用的运算符
是对以上代码中的for循环提示的
希望能帮我分析一下
谢谢
3 楼
chenminxia [专家分:0] 发布于 2010-11-22 22:59:00
谢谢啊 我知道哪里错了 正确代码如下
#include<stdio.h>
int main (void)
{
int readnum;
int i;
int numprinted;
int numbers[50];
printf("how many numbers would you like ?");
scanf("%d",&readnum);
if(readnum>=50)
readnum=50;
printf("\nenter your numbers: \n");
for(i=0;i<readnum;i++)
scanf("%d",&numbers[i]);
printf("reversed ary");
for(i=readnum-1,numprinted=0;i>=0;i--)
{
printf("%3d",numbers[i]);
if(numprinted<9)
numprinted++;
else
numprinted=0;
}
return 0;
}
我来回复