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

Discussion of Problem 1044. Lucky Tickets. Easy!

why i get compilation error ????
Posted by Hany 30 Aug 2003 18:46
#include<stdio.h>
#include<iostream.h>
#include<string.h>
char num[9];
int n;

void plus()
{
    int temp=(strlen(num)-1);
    while(num[temp]=='9')
    {
        num[temp]='0';
        temp--;
        if(temp==-1)
            break;
    }
    if(temp!=-1)
        num[temp]++;
}

bool islucky()
{
    int sum1=0,sum2=0;
    for(int c=0;c<n/2;c++)
    {
        sum1+=num[c]-48;
        sum2+=num[n-c-1]-48;
    }
    if(sum1==sum2)
        return true;
    else
        return false;
}

void main()
{
    cin>>n;
    int count=1;
    char last[9];
    for(int i=0;i<n;i++)
    {
        num[i]='0';
        last[i]='9';
    }
    num[i]=NULL;
    last[i]=NULL;
    while(strcmp(num,last)!=0)
    {
        if(islucky()==true)
            count++;
        plus();
    }
    cout<<count<<endl;
}