fork download
  1. #include<iostream>
  2. #include<string>
  3. #include<algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int x, y;
  9. string st;
  10. map<int, int> Mymap;
  11. map<int, int>::iterator it;
  12.  
  13. cin>>x>>y;
  14. for(int i=x; i<=y; i++)
  15. {
  16. st="";
  17. while(x>0)
  18. {
  19. st=st+char('0'+x%10);
  20. x/=10;
  21. }
  22. int s=st.length();
  23. for(int j=0; j<s; j++)
  24. {
  25. if(st[j]=='0')Mymap[0]++;
  26. if(st[j]=='1')Mymap[1]++;
  27. if(st[j]=='2')Mymap[2]++;
  28. if(st[j]=='3')Mymap[3]++;
  29. if(st[j]=='4')Mymap[4]++;
  30. if(st[j]=='5')Mymap[5]++;
  31. if(st[j]=='6')Mymap[6]++;
  32. if(st[j]=='7')Mymap[7]++;
  33. if(st[j]=='8')Mymap[8]++;
  34. if(st[j]=='9')Mymap[9]++;
  35. }
  36. }
  37. for(it=Mymap.begin(); it!=Mymap.end(); it++)
  38. {
  39. cout<<Mymap.second()<<" ";
  40. }
  41. cout<<endl;
  42. Mymap.clear();
  43. return 0;
  44. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1 9
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:10:2: error: ‘map’ was not declared in this scope
  map<int, int> Mymap;
  ^
prog.cpp:10:6: error: expected primary-expression before ‘int’
  map<int, int> Mymap;
      ^
prog.cpp:10:6: error: expected ‘;’ before ‘int’
prog.cpp:11:6: error: expected primary-expression before ‘int’
  map<int, int>::iterator it;
      ^
prog.cpp:11:6: error: expected ‘;’ before ‘int’
prog.cpp:25:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='0')Mymap[0]++;
                  ^
prog.cpp:26:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='1')Mymap[1]++;
                  ^
prog.cpp:27:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='2')Mymap[2]++;
                  ^
prog.cpp:28:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='3')Mymap[3]++;
                  ^
prog.cpp:29:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='4')Mymap[4]++;
                  ^
prog.cpp:30:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='5')Mymap[5]++;
                  ^
prog.cpp:31:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='6')Mymap[6]++;
                  ^
prog.cpp:32:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='7')Mymap[7]++;
                  ^
prog.cpp:33:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='8')Mymap[8]++;
                  ^
prog.cpp:34:18: error: ‘Mymap’ was not declared in this scope
    if(st[j]=='9')Mymap[9]++;
                  ^
prog.cpp:37:6: error: ‘it’ was not declared in this scope
  for(it=Mymap.begin(); it!=Mymap.end(); it++)
      ^
prog.cpp:37:9: error: ‘Mymap’ was not declared in this scope
  for(it=Mymap.begin(); it!=Mymap.end(); it++)
         ^
stdout
Standard output is empty