pages:
  • 1
amin233 SAYS

include <stdio.h>

int toInt(char str); int main() { FILE *in = fopen( "a.in" ,"r" ); FILE *out= fopen( "a.out" , "w" ); int sum = 0; char Temp[10]; fscanf(in,"%s",Temp); while(!feof(in)) { sum += toInt(Temp); fscanf(in,"%s",Temp); sum += toInt(Temp); fscanf(in,"%s",Temp); fprintf(out,"%d\n",sum); sum = 0; } return 0; } int toInt(char *str) { int n = 0 ; char *b = str; while(b) { n += *b++ - '0'; n *= 10; } return n/10; }

M ALi SAYS

Hi, You don't need to use "fopen". Simply use an input function like "scanf" or "cin" for each line entered. For example use a WHILE for inputs.

Regards

amin233 SAYS

M ALi said:

Hi, You don't need to use "fopen". Simply use an input function like "scanf" or "cin" for each line entered. For example use a WHILE for inputs.

Regards

tnx but in this order what is the while Condition... while(eof) or while(true)

M ALi SAYS

I've used this: while(cin>>n)

Salehi SAYS

Please do NOT leave comments without HTML tags!
your codes and comments not readable ...
You can paste it to somewhere like as notepad.cc and then share that links here.

Although I don't read your comments, I think you have a problem with tuning visual studio codes to g++ codes.
Also I think you must be a new person to ACM and don't familar with Online Judge. So, I suggest you to read more and more and don't disappointed, if you get discouraged, think about Edison tries which is more than 1000 times!!! or think about AbouAliSina tries! or other scientifics and their tries in many times.
at the end, I wanna tell to you: ACM competitions is easy, but you must to have a good knowledge about it.

AMiR SAYS

Salehi said:

Please do NOT leave comments without HTML tags!
your codes and comments not readable ...
You can paste it to somewhere like as notepad.cc and then share that links here.

Although I don't read your comments, I think you have a problem with tuning visual studio codes to g++ codes.
Also I think you must be a new person to ACM and don't familar with Online Judge. So, I suggest you to read more and more and don't disappointed, if you get discouraged, think about Edison tries which is more than 1000 times!!! or think about AbouAliSina tries! or other scientifics and their tries in many times.
at the end, I wanna tell to you: ACM competitions is easy, but you must to have a good knowledge about it.

Thanks for your reply.

I just want to point out that it is possible to post codes here too. You can either put 4 spaces (or a tab) before each line of your code, or you can surround your code between two "```"s like this:

```

int a;

while (true) { ... }

```

You can also put your code somewhere else and share the link here. ShareCode has a paste service you can use: http://paste.sharecode.ir or in short: http://scod.ir :)