Please read the new rule regarding the restriction on the use of AI tools. ×

WeZoomIn's blog

By WeZoomIn, history, 5 years ago, In English

I'm using Codeforces custom test. When compile and run, this code yield different results,

#include <bits/stdc++.h>
using namespace std;

int k;
map<int,int> a[2];
int bar () {
	return ++k;
}
void foo () {
	a[k][1] = bar();

}
int main() {
	k=0;
	foo ();
	cout<<a[0][1]<<" "<<a[1][1]<<endl;
	return 0;
}

//GNU G++11, GNU G++14 yield "1 0"
//GNU G++17 yield "0 1"

Is there any issue about this? What is expected behavior is this case?

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it