Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

新人一次AC,C++代码,抛砖引玉

Posted by PiscesCrab at 2016-08-15 22:08:58 on Problem 3295
堆栈解法
#include<iostream>
#include<string.h>
#include<cmath>
using namespace std;
int main()
{
	char a[250];
	int b[6];
	gets(a);
	int l;
	while (a[0]!='0')
	{
		int p=1;
		for (int i=1;i<=5;i++)  b[i]=0;
		for (int i=0;i<=32&&p;i++)
		{
			int i1=i;
			for (int j=0;j<5;j++)
			{
				b[j]=i1%2;
				i1=i1/2;
			}
			l=strlen(a);
			int ls=0;
			int c[100];
			for (int j=l-1;j>=0;j--)
			{
				if (a[j]>='p'&&a[j]<='t')
				{
					ls++;
					c[ls]=b[int(a[j]-'p')];
				}
				if (a[j]=='N') c[ls]=!c[ls];
				if (a[j]=='K') 
				{
					ls--;
					c[ls]=(c[ls]&&c[ls+1]);
				}
				if (a[j]=='A')
				{
					ls--;
					c[ls]=(c[ls]||c[ls+1]);
				}
				if (a[j]=='E')
				{
					ls--;
					c[ls]=(c[ls]==c[ls+1]);
				}
				if (a[j]=='C')
				{
					ls--;
					c[ls]=((!c[ls])||c[ls+1]);
				}
				
			
			}
		    if (!c[1]) p=0;
	    }
	    if (p) cout<<"tautology\n";
	    else cout<<"not\n";
	    gets(a);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator