vs2012的问题

chen6969354 2014-07-18 03:04:46

#include<stdio.h>
void main()
{
int K=0;
int Hp=0;
int Hs=0;
printf("输入 Hp Hs");
scanf("%d,%d",&Hp,&Hs);
K=(Hp-Hs)/Hp*100%
printf("输出" +K);
}

1>------ 已启动全部重新生成: 项目: Project2, 配置: Debug Win32 ------
1> 源.cpp
1> Project2.vcxproj -> c:\users\h430\documents\visual studio 2012\Projects\Project2\Debug\Project2.exe
========== 全部重新生成: 成功 1 个,失败 0 个,跳过 0 个 ==========


为什么调试的时候,输入
回车键之后直接跳出来,显示
“Project2.exe”(Win32): 已加载“C:\Users\H430\Documents\Visual Studio 2012\Projects\Project2\Debug\Project2.exe”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\ntdll.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\kernel32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\KernelBase.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\apphelp.dll”。已加载符号。
SHIMVIEW: ShimInfo(Complete)
“Project2.exe”(Win32): 已加载“C:\Windows\apppatch\AcLayers.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\msvcrt.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\user32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\gdi32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\shell32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\shlwapi.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\oleaut32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\mpr.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\setupapi.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\sfc.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\winspool.drv”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\rpcrt4.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\combase.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\cfgmgr32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\devobj.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\sspicli.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\sfc_os.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\cryptbase.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\sechost.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\bcryptprimitives.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\imm32.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\msctf.dll”。已加载符号。
“Project2.exe”(Win32): 已加载“C:\Windows\SysWOW64\msvcr110d.dll”。已加载符号。
程序“[7528] Project2.exe”已退出,返回值为 0 (0x0)。
...全文
196 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
牙牙学语 2014-07-22
  • 打赏
  • 举报
回复
有什么问题吗???数字 之间加个逗号呀。怎么这么多回复还没搞定???
勤奋的小游侠 2014-07-22
  • 打赏
  • 举报
回复
(5-3)/5的结果就是0。这是C++的最基本常识!!!
chen6969354 2014-07-22
  • 打赏
  • 举报
回复
引用 7 楼 lovesmiles 的回复:
[quote=引用 6 楼 Hwy_dk 的回复:] [quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。[/quote] 结果是这样的 改成%f结果是 为什么呢? 是不是代码哪里错了啊?
chen6969354 2014-07-22
  • 打赏
  • 举报
回复
引用 13 楼 zhao4zhong1 的回复:
Format Specification Fields: scanf and wscanf Functions A format specification has the following form: %
  • [width] [{h | l | I64 | L}]type The format argument specifies the interpretation of the input and can contain one or more of the following: White-space characters: blank (' '); tab ('\t'); or newline ('\n'). A white-space character causes scanf to read, but not store, all consecutive white-space characters in the input up to the next non–white-space character. One white-space character in the format matches any number (including 0) and combination of white-space characters in the input. Non–white-space characters, except for the percent sign (%). A non–white-space character causes scanf to read, but not store, a matching non–white-space character. If the next character in stdin does not match, scanf terminates. Format specifications, introduced by the percent sign (%). A format specification causes scanf to read and convert characters in the input into values of a specified type. The value is assigned to an argument in the argument list. The format is read from left to right. Characters outside format specifications are expected to match the sequence of characters in stdin; the matching characters in stdin are scanned but not stored. If a character in stdin conflicts with the format specification, scanf terminates, and the character is left in stdin as if it had not been read. When the first format specification is encountered, the value of the first input field is converted according to this specification and stored in the location that is specified by the first argument. The second format specification causes the second input field to be converted and stored in the second argument, and so on through the end of the format string. An input field is defined as all characters up to the first white-space character (space, tab, or newline), or up to the first character that cannot be converted according to the format specification, or until the field width (if specified) is reached. If there are too many arguments for the given specifications, the extra arguments are evaluated but ignored. The results are unpredictable if there are not enough arguments for the format specification. Each field of the format specification is a single character or a number signifying a particular format option. The type character, which appears after the last optional format field, determines whether the input field is interpreted as a character, a string, or a number. The simplest format specification contains only the percent sign and a type character (for example, %s). If a percent sign (%) is followed by a character that has no meaning as a format-control character, that character and the following characters (up to the next percent sign) are treated as an ordinary sequence of characters, that is, a sequence of characters that must match the input. For example, to specify that a percent-sign character is to be input, use %%. An asterisk (*) following the percent sign suppresses assignment of the next input field, which is interpreted as a field of the specified type. The field is scanned but not stored.
这是什么?
赵4老师 2014-07-22
  • 打赏
  • 举报
回复
Format Specification Fields: scanf and wscanf Functions A format specification has the following form: %
  • [width] [{h | l | I64 | L}]type The format argument specifies the interpretation of the input and can contain one or more of the following: White-space characters: blank (' '); tab ('\t'); or newline ('\n'). A white-space character causes scanf to read, but not store, all consecutive white-space characters in the input up to the next non–white-space character. One white-space character in the format matches any number (including 0) and combination of white-space characters in the input. Non–white-space characters, except for the percent sign (%). A non–white-space character causes scanf to read, but not store, a matching non–white-space character. If the next character in stdin does not match, scanf terminates. Format specifications, introduced by the percent sign (%). A format specification causes scanf to read and convert characters in the input into values of a specified type. The value is assigned to an argument in the argument list. The format is read from left to right. Characters outside format specifications are expected to match the sequence of characters in stdin; the matching characters in stdin are scanned but not stored. If a character in stdin conflicts with the format specification, scanf terminates, and the character is left in stdin as if it had not been read. When the first format specification is encountered, the value of the first input field is converted according to this specification and stored in the location that is specified by the first argument. The second format specification causes the second input field to be converted and stored in the second argument, and so on through the end of the format string. An input field is defined as all characters up to the first white-space character (space, tab, or newline), or up to the first character that cannot be converted according to the format specification, or until the field width (if specified) is reached. If there are too many arguments for the given specifications, the extra arguments are evaluated but ignored. The results are unpredictable if there are not enough arguments for the format specification. Each field of the format specification is a single character or a number signifying a particular format option. The type character, which appears after the last optional format field, determines whether the input field is interpreted as a character, a string, or a number. The simplest format specification contains only the percent sign and a type character (for example, %s). If a percent sign (%) is followed by a character that has no meaning as a format-control character, that character and the following characters (up to the next percent sign) are treated as an ordinary sequence of characters, that is, a sequence of characters that must match the input. For example, to specify that a percent-sign character is to be input, use %%. An asterisk (*) following the percent sign suppresses assignment of the next input field, which is interpreted as a field of the specified type. The field is scanned but not stored.
chen6969354 2014-07-22
  • 打赏
  • 举报
回复
引用 7 楼 lovesmiles 的回复:
[quote=引用 6 楼 Hwy_dk 的回复:] [quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。[/quote] 哦 可以了 不过为什么结果都是1呢?
chen6969354 2014-07-22
  • 打赏
  • 举报
回复
引用 9 楼 lovesmiles 的回复:
[quote=引用 8 楼 chen6969354 的回复:] [quote=引用 7 楼 lovesmiles 的回复:] [quote=引用 6 楼 Hwy_dk 的回复:] [quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。[/quote] 一样的额、、、还是不行 回车键了就直接关掉了[/quote] 仔细看别人的回复,你的代码写错了[/quote] #include<stdio.h> void main() { int K=0; int Hp=0; int Hs=0; printf("输入 Hp,Hs"); scanf("%d,%d",&Hp,&Hs); K=(Hp-Hs)/Hp; printf("%d", K); } 这样的啊
chen6969354 2014-07-22
  • 打赏
  • 举报
回复
引用 9 楼 lovesmiles 的回复:
[quote=引用 8 楼 chen6969354 的回复:] [quote=引用 7 楼 lovesmiles 的回复:] [quote=引用 6 楼 Hwy_dk 的回复:] [quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。[/quote] 一样的额、、、还是不行 回车键了就直接关掉了[/quote] 仔细看别人的回复,你的代码写错了[/quote] #include<stdio.h> void main() { int K=0; int Hp=0; int Hs=0; printf("输入 Hp,Hs"); scanf("%d,%d",&Hp,&Hs); K=(Hp-Hs)/Hp; printf("%d\n", K); } 代码早就改了啊 还是不行啊 同样的问题啊
勤奋的小游侠 2014-07-22
  • 打赏
  • 举报
回复
引用 8 楼 chen6969354 的回复:
[quote=引用 7 楼 lovesmiles 的回复:] [quote=引用 6 楼 Hwy_dk 的回复:] [quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。[/quote] 一样的额、、、还是不行 回车键了就直接关掉了[/quote] 仔细看别人的回复,你的代码写错了
chen6969354 2014-07-22
  • 打赏
  • 举报
回复
引用 7 楼 lovesmiles 的回复:
[quote=引用 6 楼 Hwy_dk 的回复:] [quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。[/quote] 一样的额、、、还是不行 回车键了就直接关掉了
勤奋的小游侠 2014-07-18
  • 打赏
  • 举报
回复
引用 6 楼 Hwy_dk 的回复:
[quote=引用 5 楼 chen6969354 的回复:] 照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。[/quote] 这是程序正常退出。你用ctrl + F5运行看一下。
Hwy_dk 2014-07-18
  • 打赏
  • 举报
回复
引用 5 楼 chen6969354 的回复:
照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
----------------------------------------- 在么,加我Q657225124一起学吧,我也是刚学的。
chen6969354 2014-07-18
  • 打赏
  • 举报
回复
照你们的都试过了 还是不行 就是调试的时候 输入数字 按回车就直接弹出来了 显示是 程序“[13388] Project2.exe”已退出,返回值为 0 (0x0)。 无法完整运行啊 是不是系统关系?
Hwy_dk 2014-07-18
  • 打赏
  • 举报
回复
#include<stdio.h> void main() { int K=0; int Hp=0; int Hs=0; printf("输入 Hp Hs"); scanf("%d%d", &Hp, &Hs); K = (Hp-Hs) / Hp * 100; printf("%d", K); } ------------------------------------------------------------ 我也是初学的,刚复制.改了一下. K = (Hp-Hs) / Hp * 100% 这个表达式这里错了。 %号是取余。 printf("输出" +K); 这是什么玩意儿……
赵4老师 2014-07-18
  • 打赏
  • 举报
回复
输入的两个数之间用半角逗号间隔。
Cnwanglin 2014-07-18
  • 打赏
  • 举报
回复
#include<stdio.h> void main() { int K=0; int Hp=0; int Hs=0; printf("输入 Hp Hs"); scanf("%d,%d",&Hp,&Hs); K=(Hp-Hs)/Hp*100; printf("输出k=%d, hp=%d, hs=%d\n", K, Hp, Hs); system("pause"); }
Cnwanglin 2014-07-18
  • 打赏
  • 举报
回复
K=(Hp-Hs)/Hp*100% printf("输出" +K); 这句什么意思? K = ... ; printf("输出k=%d",K);

64,639

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧