[Solved] Get Substring – everything before and after certain characters [closed]

You could use regular expressions, e.g: class Program { static void Main(string[] args) { var input = ” SUCCESS Post Policy Success INVOICE No. :: WS1704003404 || Policy No :: 59203313 || App No. :: 123456724 “; var pattern = @”::\s*(\w+)\s*”; var matches = Regex.Matches(input, pattern); foreach (Match match in matches) Console.WriteLine(match.Groups[1].Value); } } 1 … Read more

[Solved] How to return “” OR empty when value of float is 1

You have marked this as C++ (4-1i) should be shown as (4-i) You might find std::stringstream helpful. It simplifies the special handling for the imaginary part: virtual int foo() { std::cout << std::endl; show(4, -2); show(5, -1); return(0); } void show(int real, int imaginary) { std::stringstream ss; // default is blank if (-1 == imaginary) … Read more

[Solved] Get last “ordered” number [closed]

Here’s working code. Although I don’t like just giving you the answer. This is something you have to practice and learn how to do on your own. Take the time to understand what I did. Also, this solution can be improved a lot, just something that I did quickly and works. The algorithm in action: … Read more

[Solved] How to debug my C++ program that calculates CGPA?

You have some problems in your code: What happens if user input is larger then 10? you assume it will be smaller (you will get undefined behavior since the array size is 10, and your for loop runs until user input) int g,h,i,a=0, grade[g],hour[h]; – what is the size of grade and hour? you can … Read more

[Solved] Competition Problem: Finding numbers containing “2020” from 1 to N which is a multiple of 2020 faster than O(N/2020) [closed]

If you get stuck here’s a solution import math baseInt = 2020 #This is the int you want to find within the other int randomInt = 1012020 #This is the int you’re going to count up to def checkBaseInt(baseInt, theIteratorInt): theNumString = str(theIteratorInt) #Converting to strings to find the substring baseIntString = str(baseInt) if(theNumString.find(baseIntString) == … Read more

[Solved] Ubuntu Cronjob with rsync

To reduce the amount of space you use significantly, you’ll need to reduce the number of copies you keep. This is the 2nd argument to the script. So if you run every 3 days, and want to keep a month of backups, change it to: ../rsyncsnapshot.sh daily 10 0 solved Ubuntu Cronjob with rsync

[Solved] Write a program in C# which uses Iterative Binary Search algorithm to search age of the person using his / her name

I do disagree with the way you store your input but you can achieve your search with the following: String[,] arr = new string[2,4]; arr[0, 0] = “saif”; arr[0, 1] = “25”; arr[0, 2] = “ali”; arr[0, 3] = “17”; arr[1, 0] = “aakif”; arr[1, 1] = “11”; arr[1, 2] = “hassnain”; arr[1, 3] = … Read more