[ create a new paste ] login | about

Link: http://codepad.org/xwoZ43rY    [ raw code | output | fork ]

C++, pasted on Feb 5:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;

static const double EPS = 1e-9;
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<EPS; }
#define PI	(3.14159265358979323846)
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
double SQSUM(double x,double y) { return x*x+y*y; }
#define SZ(a) ((int)a.size()) 

class OperationsArrangement {
public:
	string arrange(string sequence) {
		string result;

		//----- 0あり -----
		if(sequence.find("0")!=string::npos)
		{
			for(int i=0;i<SZ(sequence);i++)
			{
				result += string(1,sequence[i]);
				if(i<SZ(sequence)-1)
				{
					result += "*";
				}
			}
			return result;
		}

		//----- 0ăȘし -----

		int kaketame = 1;

		for(int i=0;i<SZ(sequence);i++)
		{
			if(i!=0)
			{
				if(kaketame==1)
				{
					result += "*";
				}
				else if(kaketame==2)
				{
					if(sequence[i]<='2')
					{
						result += "*";
					}
					else
					{
						result += "+";
					}
				}
				else 
				{
					if(sequence[i]=='1')
					{
						result += "*";
					}
					else
					{
						result += "+";
					}
				}
			}

			if(i==0)
			{
				kaketame = (sequence[i]-'0');
			} else if (result[i*2-1]=='*')
			{
				kaketame *= (sequence[i]-'0'); 
			}
			else
			{
				kaketame = (sequence[i]-'0');
			}

			result += string(1,sequence[i]);
		}

		return result;
	}

	

};



// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003]
// Powered by CodeProcessor


Output:
1
2
In function `_start':
undefined reference to `main'


Create a new paste based on this one


Comments: