在PAT刷题过程的一些经验

来源:互联网 发布:整站源码带数据下载 编辑:程序博客网 时间:2024/06/06 13:04
格式问题
精确到xx位
>  #include< iomanip >>  cout << fixed << setprecision(1) << 6.000;

: 按前置0的形式读取和输出数字:比如读取 0005, 和将5输出为0005

>  #include<iomanip>>  int a;>  cin >> a; //enter 05;>  cout << setfill('0') << setw(4) << a;
ACMer的常用宏
常用操作
>   #define rep(i,j,k) for (int i=j ; i<=k ; i++)>   #define per(i,j,k) for (int i=j ; i>=k ; i--)>   #define mp(i,j) make_pair(i,j)>   #define pb push_back

: 常用名

>   #define ff first>   #define ss second>   typedef long long LL;
样例测试方法
使用fstream的方法:先把测试用例复制进txt中,然后代码中将txt路径和txt名载入到文件输入流中,把这个“流”对象当输入用
>   #include<fstream>    //for example, txt named "my.txt", in disk C>   ifstream in("c:\\my.txt");    //if there's only an integer in txt file>   int a;>   in >> a;>   cout << a;    //don't forget close it>   in.close();
0 0
原创粉丝点击