Because scanf stops input after getting space, here you can take input by scanf and sore it in an array. u should take input as a string and then by searching the array give the output
here is my code:
[cpp]
#include<stdio.h>
#include<string.h>

struct d
{
char a[100];
long num;

}data[100];
long nc;

long check(char n[])
{
long i;
for(i=0;i<nc;i++)
if(!strcmp(data.a,n))
return i;

strcpy(data.a,n);
nc++;
return i;

}

void main()
{
long b,i;
char n[100];
nc=0;
//freopen("484.in","r",stdin);

to rakeb:
I test and submit your source code, but judge send me "Runtime Error (SIGSEGV)". Therefore, I think you can check your code again. Maybe you could tell me whether it can run correctly.

I got AC,and I offer some information about this problem:

1.the integer number(positive/negative/zero) is ranged from 65535
to -65536,so you can use scanf("%d",&XXX);
2.The amout of all integers is below 10000.

Hello, I try to solve this problem but get WA.
If the input is ranged from 65535 to -65536 and is below 10000, it should work.
Can anyone have any opinion?

Last edited by Eric on Sat Jan 31, 2004 6:35 am, edited 2 times in total.

I wonder if there are trailing spaces in the input......
What can I do if so?? (I'm using Pascal......)

I couldn't find any mistakes in my code. My algorithm is:
1. Input number
2. If first occurence then
...2.1 increment n
...2.2 and store the number in an array
...2.3 set occurence = 1
3. else
...3.1 increment occurence
4. Back to step 1
5. Output

What should I do??? Please help!!!!!!

7th Contest of Newbies Date: December 31st, 2011 (Saturday) Time: 12:00 - 16:00 (UTC) URL: http://uva.onlinejudge.org

Read the input line by line into a string, and extract the numbers from this string by processing the line.

It's a bit of a spoiler, but consider this little program[pascal]{$MODE DELPHI}

program test;

function line2nums(var line:ansistring;var num:array of integer):integer;
var
i,j,len:integer;
begin
result:=0;
len:=length(line);
i:=1;
while (i<=len) do begin
while ((i<=len) and not (line in ['-','0'..'9'])) do inc(i);
j:=i;
while ((i<=len) and (line in ['-','0'..'9'])) do inc(i);
if (i>j) then begin
val(copy(line,j,i-j),num[result]);
inc(result);
end;
end;
end;

var
num:array[1..1000] of integer;
line:ansistring;
nums,i:integer;
begin
line:=' -9 3 22222 9847 rubbish -123456 more rubbish 777 ';
nums:=line2nums(line,num);
for i:=1 to nums do writeln(num);
end.[/pascal]
It compiles using FPC, the same compiler the judge uses, but certainly not with BP (I don't know about Delphi). No comments, you should be able to figure out what it does. Use ansistring, string is to short for this particular input. The val() procedure makes it a little slow, so write your own if you want more speed. The function can't cope with monsters like ('123-456'), but I don't think they are there.

i am having trouble with the prob 484 . i cant take the input of the prob. as it is a multiple input prob so the output for differnet input block should be different (with a new line).but my programs gives the output together .
tha means the complete out put together. here is my code , and sorry for my not so good english;
pliz tell me if there are any efficient algorithm. is my process right??
thanx in advance
Riyad

/* start of code*/
/*----------------*/
#include<stdio.h>

#define size 10000

struct num{
long int n;
int fr;

};

struct num obj[size];

int index;
long int input[size];
int iindex;

void init(){

register int i;
index=iindex=0;
for(i=0;i<size;i++){
obj.fr=0;

}

}

int search(int x)
{
register int i;
for(i=0;i<index;i++){
if(obj.n==x){
return i;

}

}
return -1;

}

void calculate(){

register int i,check ;
for(i=0;i<iindex;i++){

if(i==0){

obj[index].n=input;
obj[index].fr=1;
index++;

}

else{

check=search(input);
if(check!=-1){

obj[check].fr++;
}
else if(check==-1){

obj[index].n=input;
obj[index].fr=1;
index++;
}

}

}

}

void print(){

register int i;
for(i=0;i<(index-1);i++){

printf("%ld %d\n",obj.n,obj.fr);
}

}

int main(){

//freopen("input.in","rt",stdin);
register int cinput;
scanf("%d",&cinput);
while(cinput>0){

init();

while(scanf("%ld",&input[iindex++])!=EOF){

;
}

calculate();
print();
printf("\n");
cinput--;

}

return 0;
}
/*----------------*/
/*end of code */

HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN

thanx buddy i got it ac now . i some how made a stupid mistake by considering 484 as a multiple input problem . problems like this can be made by we new people. thanx once agian for u r help.
bye
Riyad

HOLD ME NOW ,, I AM 6 FEET FROM THE EDGE AND I AM THINKIN.. MAY BE SIX FEET IS SO FAR DOWN