ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Why do I get Compilation Error?
Posted by Igor3T 7 Oct 2006 00:52
I won't say you what problem is it.
I get compilation error for this code:
// forograf.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

#define ex4(wer,ser) {int t=mas[f]; mas[f]=mas[i]; mas[i]=t;}

int mas[60];
    int n,vars=0;
bool sum_next;

bool can_swap(int a, int b)
{
    if (a!=b)
    {
        if ((a>1)&&(b<n-1))
        {
        if ((abs(mas[a-1]-mas[b])<3) &&
            (abs(mas[a+1]-mas[b])<3) &&
            (abs(mas[a]-mas[b-1])<3) &&
            (abs(mas[a]-mas[b+1])<3))
                return(true); else return(false);
        } else
    if     ((abs(mas[a-1]-mas[b])<3) &&
            (abs(mas[a+1]-mas[b])<3) &&
            (abs(mas[a]-mas[b-1])<3))
                return(true); else return(false);
    } else return(false);
}

int get_var(int f)
{
    int c=0;
    if (f==n) return(0);
    for ( ; (f<n)&&(sum_next); f++)
    for (int i=f+1; i<n; i++)
        if (can_swap(f,i))
        {
            ex4(f,i);
            if (sum_next) vars++;
            get_var(f+1);
            ex4(f,i);
        }
    sum_next=false;}

int _tmain()
{
    cin >> n;
    for (int i=0; i<n+2; i++) mas[i]=i+1;

    for (int i=n; i>1; i--) {
        sum_next=true; get_var(i-1); }

    cout << vars+1;

    return 0;
}

Why? I use Microsoft Visual Studio 2005 (C++)



Edited by author 07.10.2006 00:55

Edited by author 07.10.2006 00:55
Re: Why do I get Compilation Error?
Posted by Soul Reaver 30 Oct 2006 21:45
Becouse not _tmain it mast be only main() :)