遇到卡时间比较死的题目的时候可以用
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> using namespace std; //适用于正负整形数 template <class T> inline bool scan_d(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; //EOF while (c != '-' && (c<'0' || c>'9')) c = getchar(); sgn = (c == '-') ? -1 : 1; ret = (c == '-') ? 0 : (c - '0'); while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0'); ret *= sgn; return 1; } inline void out(long long x) { if (x > 9)out(x / 10); putchar(x%10+'0'); } int main() { int n;long long p[100]; scanf("%d",&n); for (int i = 0; i < n; i++) scan_d(p[i]); for (int i = 0; i < n; i++) { out(p[i]); printf("\n"); } return 0; }
原文地址:http://blog.csdn.net/u014427196/article/details/44281183