How do I append to a string in C and write that modification back to the original string?
It is my first day writing programs in C and am confused as to why this code does not work. I have programmed before in C#.
How to find all positions of multiple substrings within a string in C++
I want to use the #include
directive in GLSL files so I don’t have to rewrite the same code for every GLSL shader I create. I tried to create my own small parser for this purpose, but I couldn’t find a good way to locate all #include
statements in a GLSL file. I want to extract the paths of the included files, read them, and write their content into the actual shader (not the original GLSL file that uses the #include directive, but the content read into a std::string
).
How to find all positions of multiple substrings within a string in C++
I want to use the #include
directive in GLSL files so I don’t have to rewrite the same code for every GLSL shader I create. I tried to create my own small parser for this purpose, but I couldn’t find a good way to locate all #include
statements in a GLSL file. I want to extract the paths of the included files, read them, and write their content into the actual shader (not the original GLSL file that uses the #include directive, but the content read into a std::string
).
When using the String.Remove() method, what am I missing?
I’m relatively new to C#, and am working through a problem whereby I need to strip out all the non-alphanumeric characters within a string.
my code gives time limit reached please fix my code
Today while solving a question on leetcode, I applied dfs on a directed graph which runs on O(N) time, but my code is giving TLE, so after trying too many time I checked on comments and there was a accepted code which also runs on O(N). So now I am confused as why my code is not getting accepted and giving time limit exceeded. My code:-
Check if string has any consecutive repeating substring in it
I want to accept only strings that do not have any substring repeated three times consecutively in them. The substring is not known in advance. For example, “a4a4a4123” contains “a4”; “abcdwwwabcd” – “w”; “abcde” – valid, no triple repeats.
Check if string has any consecutive repeating substring in it
I want to accept only strings that do not have any substring repeated three times consecutively in them. The substring is not known in advance. For example, “a4a4a4123” contains “a4”; “abcdwwwabcd” – “w”; “abcde” – valid, no triple repeats.
Text after the space is not being printed
I take in a string (e.g. 3 6) the string will always be two one digit numbers separated by one space. I have access to the first number, but for some reason I loose access to the second one.
Command exited with non-zero status 124
#include <bits/stdc++.h> using namespace std; int main() { size_t t,n,m,k;cin>>t; string a; while(t–){ cin>>n>>m>>k>>a; if(m>n){ cout<<“YESn”; continue;} for(size_t i=0;i<n;){ if(i=a.find(“L”,i))!=string::npos){ if(m+k>=a.find(“L”,i)){ if(n-i<=m+k) {cout<<“YESn”; break;} } else{ cout<<“NOn”; break;} }} } return 0; } so basically i have to cross a river of length n , with C (crocodiles) ,L(logs) in it but upon running it […]
terminate called after throwing an instance of ‘std::out_of_range’ what(): basic_string::erase: __pos (which is 18446744073709551615)
#include <bits/stdc++.h> using namespace std; int main() { string a,b; cin >> a; b=”WUB”; int n; while(a.find(b)==0){ a.erase(0,3); } while(a.find(b)>0){ n=a.find(b); a.replace(n,3,” “); } n=a.size(); while(a[–n]==’ ‘){ a.erase(n,1); } cout<<a; return 0; } basically i have to remove WUB from the input string and if its between words then switch it with space but i […]