Answer the question
In order to leave comments, you need to log in
Replace each '+' character in a string with a '-' character if the '+' is preceded by an odd number?
The essence of the task in a string (String or StringBuilder) is to replace each '+' character in a string with a '-' character if there is an odd number before the '+'.
I'm trying to do it somehow through the last character (digit), if the number ends with an odd number, then it itself is not even
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace labor4
{
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
string[] subs = sb.Split(' ', '+', '-', '*', '/');
foreach (var sub in subs)
{
char n = sub.Last();
if (n=='1'|n=='3'|n=='5'|n=='7'|n=='9')
{
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question