- 1
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; }
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
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)
I've used this: while(cin>>n)
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.
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 :)
In order to post something you must login first. You can use the form in the top of this page.