积极答复者
对开始编程的疑惑

问题
答案
-
-
#include<stdio.h>
int main()
{
int n,sum=0;
printf ("请输入一个数:");
scanf("%d",&n);
while (n<=50)
{
sum=sum+n;
n++;
}
printf("sum=%d\n",sum);return 0;
}
麻烦把正确答案设为解答。- 已标记为答案 Jesse JiangModerator 2010年12月7日 7:58
-
经你的指出,程序能运行了。谢谢啦。对了,你能告诉我这是什么原因吗?我的那本书上是“;”而不是“,”是不是在vs2008里面能运行还是别的原因啊。
;用在语句的结尾那么这样的话 int n;sum=0;
这样的话sum 就没有类型的标示,所以会报错。
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- 已标记为答案 Jesse JiangModerator 2010年12月7日 7:58
全部回复
-
您好,
首先您要确定一下是不是因为第三方插件引起的,我们可以设置VS safe mode来排除其他插件的干扰,具体请参见
http://msdn.microsoft.com/en-us/library/ms241278(VS.80).aspx
Regards!
Jesse
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
#include<stdio.h>
void main()
{
int n;sum=0;
printf ("请输入一个数:");
scanf("%d",&n);
while (n<=50)
{
sum=sum+n;
n++;
}
printf("sum=%d\n",sum);
}下面是输出的:
1>------ 已启动生成: 项目: my program, 配置: Debug Win32 ------
1>生成启动时间为 2010/11/30 13:43:50。
1>InitializeBuildStatus:
1> 正在对“Debug\my program.unsuccessfulbuild”执行 Touch 任务。
1>ClCompile:
1> 所有输出均为最新。
1>ManifestResourceCompile:
1> 所有输出均为最新。
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: 无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用
1>C:\Users\peter\documents\visual studio 2010\Projects\my program\Debug\my program.exe : fatal error LNK1120: 1 个无法解析的外部命令
1>
1>生成失败。
1>
1>已用时间 00:00:02.28
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ========== -
您可能是建立项目的方式不对,您应该建立控制台程序,而不是win32程序
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
-
#include<stdio.h>
int main()
{
int n,sum=0;
printf ("请输入一个数:");
scanf("%d",&n);
while (n<=50)
{
sum=sum+n;
n++;
}
printf("sum=%d\n",sum);return 0;
}
麻烦把正确答案设为解答。- 已标记为答案 Jesse JiangModerator 2010年12月7日 7:58
-
经你的指出,程序能运行了。谢谢啦。对了,你能告诉我这是什么原因吗?我的那本书上是“;”而不是“,”是不是在vs2008里面能运行还是别的原因啊。
;用在语句的结尾那么这样的话 int n;sum=0;
这样的话sum 就没有类型的标示,所以会报错。
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- 已标记为答案 Jesse JiangModerator 2010年12月7日 7:58