0

I am trying to submit my code on codeforce but it is giving me compilation error even my code is working properly on my laptop can anyone tell whats wrong with it

#include <iostream>
#include<cstring>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    int n,m;
    while((cin>>n>>m) != NULL)
    {
       if(n<m)
       {
           int t=n;
           n=m;
           m=t;
       }
       cout<<m<<' ';
       n-=m;
       cout<<n/2<<endl;
    }
    return 0;
}

Here is my solution link https://codeforces.com/problemset/submission/581/143323210

  • 2
    Where did you get the idea that `!= NULL` would be a good idea? Wherever it was, ignore it and get [a good book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Jan 19 '22 at 12:28
  • Why don't you pass your code to gcc, clang or some other compiler and look at the error message? That's probably helpful. – bitmask Jan 19 '22 at 12:30
  • If I recall correctly there was once a cast operator to `void*` – but that has gone since long. If your code compiles on your system then you are operating on a hopelessly outdated compiler. Nowadays the streams provide a cast operator to `bool`, so you'd simply write `while(cin >> n >> m)`. That would work for the `void*` cast operator as well – still you should get a more recent compiler... – Aconcagua Jan 19 '22 at 12:35
  • Your code compiles with c++98 but since c++11 it won't – t.niese Jan 19 '22 at 12:36
  • This works in C++98, but not with the later standards. You may want to upgrade the compiler on your laptop with one that defaults to C++17, such as the last version of MSVC , gcc or clang. – n. m. could be an AI Jan 19 '22 at 12:36
  • Side note: About [`using namespace std`](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice)... – Aconcagua Jan 19 '22 at 12:36

1 Answers1

0

Use this one "while((cin >> n >> m))".

A4F9
  • 76
  • 2