scanf参数输入问题
来源:互联网 发布:医用心理测评软件 编辑:程序博客网 时间:2024/06/07 09:40
1、scanf("%d%d%d",&a,&b,&c) /*此处输入的时候需要根据""内的格式进行*/
如果在同一行输入的话,3个数直接要用 空格 隔开。---原理不明,需要研究scanf机理。
如果是单独分3行输入的话,则每输入一个就回车一下。---回车好像是 flush 的作用。
2、scanf("%d,%d,%d",&a,&b,&c)) /*此处输入的时候需要根据""内的格式进行*/
此时只能在同一行中输入,且3个数之间要用逗号隔开。
附一个小程序:
#include<stdio.h>
int main()
{
int a,b,c;
printf("please input the length of the triangle three lines:");
if(3 != scanf("%d,%d%d",&a,&b,&c)) /*此处输入的时候需要根据""内的格式进行*/
{
printf("the input is error/n");
}
if((a+b>c)&&(a+c>b)&&(b+c>a))
{
if((a == b)&&(a == c))
{
printf("等边三角形/n");
}
else if((a == b)||(a == c)||(b == c))
{
printf("等腰三角形/n");
}
else
{
printf("不等边三角形/n");
}
}
else
{
printf("the inputs can't be a triangle/n");
}
return 0;
}
- scanf参数输入问题
- scanf输入参数详解
- scanf()函数的参数输入类型不匹配问题
- scanf输入数组问题
- scanf输入字符串问题
- scanf输入问题
- scanf参数问题
- Scanf函数的输入问题
- scanf的安全输入问题
- scanf引出的输入缓冲区问题
- scanf读输入缓存引发的问题
- scanf输入时候的\n问题
- scanf输入格式的一些问题
- scanf输入字符和数字的问题
- OJ上scanf的输入问题
- OJ上scanf的输入问题
- scanf输入
- scanf函数参数不匹配问题
- 周四 某著名网络公司应聘经过
- linux zImage生成过程详解
- j2me-使用指针设备
- 大学生
- 类的加载,连接,初始化详解
- scanf参数输入问题
- struts连接数据库
- 通过分析SQL语句的执行计划优化SQL(四)
- 09中国IC老杳榜7:十大IC新闻事件
- checkstyle中文教程
- 解析Java类和对象的初始化过程
- 如何写robots.txt
- 电脑“中毒门”续
- .Net操作Excel后彻底释放资源