嘻嘻嘻,想不到吧

万能头文件 #include<bits/stdc++.h>

floor(x)向下取整,返回一个<=x的int整型。
ceil(x)向上取整,返回一个>=x的int整型。

PI

const double PI = atan(1.0)*4;
const double PI = acos(-1.0);

四舍五入

cout << floor(resu+0.5) <<endl;
printf("%.0lf\n",resu);

头文件在#include<limits.h>中,直接#include<bits/stdc++.h>也可
cout<<"INT_MAX="<<INT_MAX<<endl<<"ULONG_MAX="<<ULONG_MAX<<endl<<"LONG_MAX="<<LONG_MAX<<endl;

输入挂之二
inline int getin()
{
int ans=0;char tmp;
while(!isdigit(tmp=getchar()));
do ans=(ans<<3)+(ans<<1)+tmp-'0';
while(isdigit(tmp=getchar()));
return ans;
}

string 出现的问题

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string st;
    cin>>st;
    int i = st.size();
    printf("str size is:%d\n",i);
    i = strlen(st.c_str());
    printf("str size is:%d(by strlen)\n",i);
    return 0;
    
}

(https://zhidao.baidu.com/question/2117495607995670467.html)

记录函数运行时间

#include<iostream>
#include<time.h>
 
using namespace std;
 
int main()
{
	clock_t startTime,endTime;
	startTime = clock();
	for (int i = 0; i < 10000000; i++)
	{
		i++;
	}
	endTime = clock();
	cout << "Totle Time : " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;

	return 0;
}
posted @ 2018-08-24 15:01  ronnie14165  阅读(145)  评论(0编辑  收藏  举报