fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string k,l;
  4. string p="";
  5. string rec(int n){
  6. string s="";
  7.  
  8. if(n!=0 && n!=1 )
  9. {
  10. if(n%2==1)
  11. {
  12. k="1";
  13. cout<<"for n="<<n<<" k="<<k<<endl;
  14. }else{
  15.  
  16. cout<<"for n="<<n<<" k="<<k<<endl;
  17. k="0";
  18. }n=n/2;
  19.  
  20. cout<<n<<endl;
  21.  
  22. s=rec(n);
  23. }
  24. else
  25. {
  26. return "1";
  27. }
  28.  
  29. l=s+k;
  30. return l ;
  31. }
  32. int main(){
  33. vector<int> v;
  34. int n,l,r;
  35. cin>>n>>l>>r;
  36. string p;
  37. p=rec(n);
  38. cout<<p;
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58. void longestsequence(string a,string b){
  59.  
  60.  
  61. getline(cin,a);
  62. getline(cin,b);
  63. int x=a.length();
  64. int y=b.length();
  65. /* if(x==0 || y==0 || a==b)
  66. {
  67. cout<<"-1";
  68. return 0;
  69. }*/
  70. int p=x+1;
  71. int q=y+1;
  72. int m[p][q]={0};
  73.  
  74. for(int i=0;i<=x;i++)
  75. for(int j=0;j<=y;j++)
  76. m[i][j]=0;
  77.  
  78. for(int i=0;i<x;i++){
  79. for(int j=0;j<y;j++)
  80. {
  81. if(a[i]==b[j])
  82. {
  83. m[i+1][j+1]=m[i][j]+1;
  84. }else
  85. m[i+1][j+1]=max(m[i][j+1],m[i+1][j]);
  86. }
  87. }
  88.  
  89. /*for(int i=0;i<=x;i++){
  90. for(int j=0;j<=y;j++)
  91. cout<<m[i][j];
  92. cout<<endl;}*/
  93. /*int k=0;
  94. int max=0,c=0;
  95. for(int j=1;j<=y;j++){
  96. if(m[x][j]==k)
  97. {
  98. c++;
  99. }
  100. else
  101. {
  102. if(c>max)
  103. max=c;
  104. c=0;
  105. k=m[x][j];
  106. }
  107. }
  108. if(c>max)
  109. max=c;
  110. c=0;
  111. k=0;
  112. for(int i=1;i<=x;i++){
  113.  
  114. if(m[i][y]==k)
  115. {
  116. c++;
  117. }
  118. else
  119. {
  120. if(c>max)
  121. max=c;
  122. c=0;
  123. k=m[i][y];
  124. }
  125. }
  126. if(c>max)
  127. max=c;
  128.  
  129. cout<<max;*/
  130. }
  131.  
  132.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
10 2 3
compilation info
prog.cpp:72:8: error: variable-sized object may not be initialized
        int m[p][q]={0};
              ^
1 error generated.
stdout
Standard output is empty