奉献给小蒟蒻们,如果啥也不会,赛前一晚看一遍
首先 我蒟蒻
其次 我蒟蒻
最后 我蒟蒻
所以我分享的都是很基础的算法或者小tips
欢迎大神指正纠错
题目中隐含的输入输出方法
按行读入,空格隔开
C++ 输入换行停止输入
string s;
getline(cin,s);
从char转int -48
扫描二维码关注公众号,回复:
17519059 查看本文章

马上给返回值
int a,b;
while(cin>>a>>b)
cout<<a+b<<endl;
return 0;
输出一行数字,中间用空格隔开,最后一个数字没有空格
for(i=0;i<m;i++)
{
printf("%d",a[i]);
if(i==m-1)//注意是==符号,很容易弄错
printf("\n");
else
printf(" ");
}
#include<cmath>
常用的数学符号
#include<cmath>
x的y次方:double pow(double x, double y);
整型绝对值:int abs(x);
向上取整:double ceil(double x);
向下取整:double floor(double x);
double sqrt (double x) 返回x的开平方
double cbrt(double x) 计算x的立方根
四舍五入的几种方法
int a=prices*100.00/n+0.5;
int b=money*100.00/n+0.5;
cout<<a<<"%"<<endl<<b<<"%"<<endl;
本期只是一些小tips,一丢丢小细节
后续再有再更