题目 输入正好是long long的最大, 但是答案超long long 所以用unsigned, 不能用cin cout否则一定超时: 不能用abs(), abs 只用于整数. unsigned   int   0-4294967295   int   2147483648-2147483647 unsigned long 0-4294967295long   2147483648-2147483647long long的最大值:9223372036854775807long long的最小值…
printf和scanf是c语言的输入输出,学习c++以后,自然是用cin cout这两个更简单的输入输出 printf scanf 都需要进行格式控制,比较麻烦,但优点是速度比较快,毕竟多做了一些事情 cin cout速度较慢,在oj上或者是竞赛时,如对时间需求较高,则最好改为printf scanf 另外,printf在控制输出格式的时候比cout更加方便 尤其是几位小数的控制输出,比如只输出两位小数,精确到两位小数,需要四舍五入 这最适合用printf     格式控制字符串为  "%x.…
C++ 可通过流的概念进行程序与外界环境( 用户.文件等 )之间的交互.流是一种将数据自源( source )推送至目的地( destination )的管道.在 C++ 中,与标准输入/输出相关的流可通过头文件 <iostream> 使用,与文件读写相关的流可以通过头文件 <fstream> 使用.这里即主要介绍 C++ 中与标准输入/输出相关的流 cin / cout . 头文件与命令空间 引入头文件 在 C++ 中,想要使用相应的标准库功能,需要包括对应的库的头文件.故而想要…
题目出处:http://codeforces.com/problemset/problem/892/B 题目大意:一队人同时举刀捅死前面一些人后还活着几个 #include<iostream> #define IO ios::sync_with_stdio(false);\ cin.tie(0);\ cout.tie(0); using namespace std; typedef __int64 LL; ; int p[maxn]; //库中有max同名 int main(){ IO;//输…
cin 表示输入流,但是究其本质,又能认识到什么呢?先上代码: #include "iostream" };//c++11中使用{}进行重新命名 int main() { using namespace std; double fish[MAX]; ////////// bool sym; int test; sym = bool(cin >> test); cout << sym << endl;//这里是用来测试cin输入如果输入的不是对应的类型…
From:http://www.cnblogs.com/killerlegend/p/3918452.html Author:KillerLegend Date:2014.8.17 杭电OJ之3233很简单的一个问题,谁知道一直提示我超时,超时,最后都快哭了,C++代码如下: #include <iostream> #include <iomanip> using namespace std; int main() { ; while(cin>>t>>tmp…
最近在练机试题,常用的C和C++输入输出如下: 1 scanf 和printf int a; scanf("%d",&a) ; printf("%d",a); printf("\n"); double b;scanf("%"); char c; scanf("%c",&c);printf("%c",c); long int a; scanf("%ld"…
转自http://www.cnblogs.com/penelope/articles/2426577.html  cin .cout   基本说明: cin是标准输入流对象,代表标准输入设备(键盘),使用方法:cin >> 变量.功能:数据通过输入设备放在缓存区,cin从缓存区中读出数据存到变量中. cout是标准输出流对象,代表标准输出设备(显示器),使用方法:cout << 变量.功能:从变量中读取数据放入缓存区,然后经输出设备显示数据. cin,cout,重载了"&…
1.C++ code, When we want to read a number whatever the type is int or double , just use cin >> Num_variable; Then, after read number, if we want to read a line of words, we have to use cin.ignore(); and next line getline(cin, String); after we read…