Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22006

My c++ program is compiling fine, but not running . My program is running and stopping for a while. No error is showing

$
0
0

My c++ program is compiling with no error. I am running my program on vscode . In the same file, when i run this code.
My system:

  1. Windows 10
  2. visual studio code
  3. c++ 14
#include<bits/stdc++.h>using namespace std;int main(){count<<"Hello";return 0;}

It is running fine.
When in the same file, i put this code,

#include<bits/stdc++.h>using namespace std;int removeAlt(string s);int removeTwo(string s,char a,char b);int alternate(string s);int main(){    cout<<alternate("abaacdabd");    return 0;}int removeAlt(string s){    // remove consicutive characters    for(int i=0;i<s.size();){        if(s[i]==s[i+1]){            s.erase(i,1);        }    }    cout<<"Remove consitutive "<<s<<endl;    return s.size();}int removeTwo(string str,char a,char b){    for(int i=0;i<str.length();){        char ch=str[i];        if(str[i]==a||str[i]==b){            str.erase(i,1);        } else i++;    }    cout<<"removing "<<a<<""<<b<<",, "<<str<<endl;    int res=removeAlt(str);    return res;}// Complete the alternate function below.int alternate(string s) {    set<char>st;    // get different character of set    for(auto x:s)        st.insert(x);    int len=st.size(); // length of set    char setAr[len];    auto it=st.begin();    for(int i=0;i<len;i++){        setAr[i]=*it;        it++;    }    cout<<"Removing\n";    int up=len;    for(int i=0;i<up-1;i++){        for(int j=i+1;j<=up;j++){            cout<<"SetAr "<<i<<""<<j<<endl;            len=max(0,removeTwo(s,setAr[i],setAr[j]));        }    }    return len;}

It runs some statements , after that terminal pauses forever. vscode run time


Viewing all articles
Browse latest Browse all 22006

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>