| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么这个代码C++编译不过 G++就A了 提示也很奇怪#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
string str;
int point[5];
int judge_ans;
int key;
//int test;
int judge()
{
stack<int>sta;
int len = str.size();
int i;
for(i = len - 1; i >= 0; --i)
{
if(str[i] >= 'p' && str[i] <= 't')
{
sta.push(point[str[i]-'p']);
}
else
{
switch(str[i])
{
case 'K':
{
int a=sta.top();
sta.pop();
int b=sta.top();
sta.pop();
int c;
if(a&&b)
{
c=1;
}
else
{
c=0;
}
sta.push(c);
break;
}
case 'A':
{
int a=sta.top();
sta.pop();
int b=sta.top();
sta.pop();
int c;
if(a==1||b==1)
{
c=1;
}
else
{
c=0;
}
sta.push(c);
break;
}
case 'N':
{
int a=sta.top();
sta.pop();
int c;
if(a)
{
c=0;
}
else
{
c=1;
}
sta.push(c);
break;
}
case 'C':
{
int a=sta.top();
sta.pop();
int b=sta.top();
sta.pop();
int c;
if(a==b)
{
c=1;
}
else
{
c=b;
}
sta.push(c);
break;
}
case 'E':
{
int a=sta.top();
sta.pop();
int b=sta.top();
sta.pop();
int c;
if(a==b)
{
c=1;
}
else
{
c=0;
}
sta.push(c);
break;
}
}
}
}
return sta.top();
}
void dp(int m,int mmax)
{
if(key)
{
return;
}
int i;
if(m==mmax)
{
int t=judge();
if(judge_ans!=-1)
{
if(t!=judge_ans)
{
key=1;
}
}
else
{
judge_ans=t;
}
return;
}
for(i=0; i<2; ++i)
{
point[m]=i;
dp(m+1,mmax);
}
}
int main()
{
while(cin>>str,str[0]!='0')
{
judge_ans=-1;
key=0;
dp(0,5);
if(key||judge_ans==0)
{
cout<<"not"<<endl;
}
else
{
cout<<"tautology"<<endl;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator