两个就是输出不一样的代码为什么结果截然不同?

P1014 [NOIP1999 普及组] Cantor 表

我代码有问题233333但是放LUOGU能过诶。。
by TaK_Vin @ 2018-03-05 20:38:15


把那个问题改过来真的还是错的QAQ ```cpp #include<cstdio> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; inline void read(int &x) { char ch=getchar(); int f=1;x=0; for( ; !isdigit(ch); ch=getchar()) if(ch=='-') f=-1; for(;isdigit(ch); x=x*10+ch-'0',ch=getchar()); x*=f; } inline void read(ll &x) { char ch=getchar(); ll f=1;x=0; for( ; !isdigit(ch); ch=getchar()) if(ch=='-') f=-1; for(;isdigit(ch); x=x*10+ch-'0',ch=getchar()); x*=f; } inline void write(int x){ int top=0;char tmp[10]=""; do{tmp[++top]='0'+x%10;x/=10;}while (x); while ( top ) putchar( tmp [ top -- ] ); } inline void write(ll x){ int top=0;char tmp[30]=""; do{tmp[++top]='0'+x%10;x/=10;}while (x); while ( top ) putchar( tmp [ top -- ] ); } inline void write(int x,char c){ int top=0;char tmp[10]=""; do { tmp[++top]='0'+x%10; x/=10; } while (x); while(top)putchar(tmp[top--]);putchar(c); } inline void write(ll x,char c){ int top=0;char tmp[30]=""; do { tmp[++top]='0'+x%10; x/=10; } while (x); while(top)putchar(tmp[top--]);putchar(c); } inline int fianl(int &x){int t=0;while (x>t)x-=t++;return t;} struct ans{int a;char c='/';int b=1;}; inline ans solve(int t,int x){ ans m;m.a=t; for (int i=1;i<x;++i)m.a--,m.b++; if (!(t&1))swap(m.a,m.b); return m; } int main(){ int x;read(x); int t=fianl(x); printf("%d%c%d\n",solve(t,x)); return 0; } ```
by TaK_Vin @ 2018-03-05 20:42:46


@[K_Vin](/space/show?uid=21836) 废话,当然不能输出结构体,想输出结构体要重载的 ```cpp ostream& operator << (ostream& out,const ans &x) { out<<x.a<<'\'<<x.b; return out; } ```
by DimensionTripper @ 2018-05-27 10:01:15


@[DimensionTripper](/space/show?uid=55454) 能输出结构体,用printf输出,顺序是结构体定义时变量的顺序,你可以试试。
by TaK_Vin @ 2018-05-29 15:05:04


@[K_Vin](/space/show?uid=21836) 欸,这么厉害吗?!
by DimensionTripper @ 2018-05-30 15:55:41


@[DimensionTripper](/space/show?uid=55454) 可能是因为我编译用了std=c++11??
by TaK_Vin @ 2018-05-31 20:05:02


|