我的第一次AC(A+B Problem (EOF))
来源:互联网 发布:java彩票程序 编辑:程序博客网 时间:2024/05/16 05:01
#include<stdio.h>
int main()
{
int a,b;
while(scanf("%d %d",&a,&b)!=EOF) //根据scanf函数的返回值在while里判断输出格式是否正确看是否进行循环体
{
printf("%d\n",a+b);
}
return 0;
}
------------------------------------------------------------------------
第一次AC成功很sexy。总结一点scanf函数返回值的问题
#include<stdio.h>
int main()
{
int a, b, c;
int x=scanf("%d%d%d",&a,&b,&c);
printf("%d %d %d\n",a,b,c);
printf("%d\n",x);
return 0;
}
当输入为int型时用这个代码表示,如果
输入1 1 1 输出 为1 1 1 scanf 为3
输入1 1 a (第三位赋值不正确)输出为1 1 0 scanf 为2
输入a 1 1 (第一位赋值不正确)输出为 1 0 0 scanf为0
可以得到scanf为输出第一位到非int型的那一位的数(不包括第一位)第一位为0 第n位为n-1
阅读全文
0 0
- 我的第一次AC(A+B Problem (EOF))
- a+b problem(EOF)
- A+B Problem (EOF)
- A+B problem(EOF)
- A+B problem(64bit Integer + EOF)
- 【第一篇blog】“从A+B Problem到我的第一次NOIP”
- A+B Problem (64bit Integer + EOF)
- A+B Problem (64bit Integer + EOF)
- 计算a+b的和 EOF结束
- A+B(EOF)
- 杭电HDU OJ A + B Problem II ID1002 AC
- [置顶]我的第一个C语言程序 (A+B Problem)(cheney-yang)
- A+B Problem(V)
- A+B Problem(水)
- (1)A+B Problem
- A+B Problem(V)
- A+B Problem(V)
- A+B Problem(高精加)
- Q&A——资源管理(八)
- kafka学习笔记:知识点整理(二)
- 嵌入式linux系统获取ip的方法
- LeetCode (Subsets II)
- 虚拟机VMware中安装CentOS7
- 我的第一次AC(A+B Problem (EOF))
- 二叉查找树的判断
- JavaScript基础
- 数据库设计:范式与反范式
- 第60讲 数组的作业讲评
- hdu 1728 逃离迷宫
- JS中String()与new String()的差异浅析
- 导入项目启动报错Unexpectedexception parsing XML document from file[H:\software\apache-tomcat-7.0.77\webapps\
- Q&A——性能优化(二)