Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Scanf and CIN giving different outputs. Please help.

$
0
0

I wrote a program and it was satisfying the test cases. I submitted the program but it gave TLE. So, I replaced all CINs with SCANFs. I don't know C, so please tell me what's going wrong.

I cannot share the entire code, because its part of an ongoing contest.

cin>>t;                        ->    scanf("%d",&t);
cin>>n>>q;                     ->    scanf("%d",&n);scanf("%d",&q);
cin>>left[i]>>right[i];        ->    scanf("%d",&left[i]);scanf("%d",&right[i]);
cout<<sum<<endl;               ->    printf("%d",sum);

EDIT: My output has changed after using scanf. Why is that happening?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>