fork(10) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct Counter{
  6. static int k;
  7. Counter(){ k++; }
  8. ~Counter() { k--; }
  9. };
  10. int Counter::k = 0;
  11. #define LOL(x) {string s = #x; Counter c##x; cout<<s.substr(0,1+s.find('['))<<Counter::k<<"]="<<x<<'\n'; }
  12.  
  13. int main()
  14. {
  15. int arr[15];
  16. for (int i = 0; i < 15; ++i) arr[i] = rand()%100;
  17.  
  18. for (int i = 0; i < 15; ++i)
  19. {
  20. LOL(arr[i]);
  21. }
  22. return 0;
  23. }
  24.  
  25.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
arr[0]=83
arr[1]=86
arr[2]=77
arr[3]=15
arr[4]=93
arr[5]=35
arr[6]=86
arr[7]=92
arr[8]=49
arr[9]=21
arr[10]=62
arr[11]=27
arr[12]=90
arr[13]=59
arr[14]=63