1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aleksley [76]
3 years ago
11

NO LINKS

Computers and Technology
1 answer:
horsena [70]3 years ago
3 0

Answer:

#include <iostream>

#include <string>

#include <regex>

using namespace std;

int main()

{

   cout << "Enter a 5-digit number: ";

   string number;

   cin >> number;

   bool valid = regex_search(number, regex("^\\d{4}[02468]$"));

   if (valid) {

       valid = stoi(number.substr(0, 1)) + stoi(number.substr(1, 1))  

           < stoi(number.substr(3, 1)) + stoi(number.substr(4, 1));

   }

   cout << number << (valid ? " is valid" : " is invalid");

}

Explanation:

Regular expressions can do all of your checking except for the sum of digits check. The checks are i.m.o. easiest if you don't treat the input as a number, but as a string with digits in it.

The regex means:

^ start of string

\d{4} exactly 4 digits

[02468] one of 0, 2, 4, 6 or 8 (this is what makes it even)

$ end of string

You might be interested in
An engine that generates hot, expanding gases by burning fuel inside the machine.
Keith_Richards [23]

Answer:

Piston engines, jet engines, and rocket engines all depend on the same basic principles to produce thrust. The engine mixes fuel with oxygen or another oxidizer in a combustion chamber. The mixture is ignited. The burning mixture creates hot, expanding gases.

Explanation:

PA BRAINLIEST

3 0
3 years ago
If we ignore the audio data in a video file, a video file is just a collection of many individual frames (i.e., images). What is
marysya [2.9K]

Answer:

It is compressing the video file to make it smaller, but doing so without actually losing any quality

Explanation:

8 0
3 years ago
What are some things that games were historically used for?
madreJ [45]

Answer:

D) All of the above

Explanation:

All of these options are true.

Hope it helps and is correct!

5 0
3 years ago
What is the point of completing a value assessment while searching for a career
juin [17]

Answer:

So you can discover Careers that you might like in a more accurate way.

Explanation:

3 0
4 years ago
Which of the following security policies can be implemented to prevent removable media from automatically launching potentially
il63 [147K]

The security policy that can be implemented to prevent removable media from automatically launching potentially harmful programs is Disable AutoRun.

<h3>Why should one disable AutoRun?</h3>

The Autorun is known to be a system function that often launches every time, and as such, it renders your system to be open to viruses, malwares, trojans etc.

Conclusively, The act of Disabling the autorun feature is one that can hinder malware from spreading in your system.

Learn more about computer from

brainly.com/question/24540334

4 0
3 years ago
Other questions:
  • PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
    6·1 answer
  • Keyshia adds shapes with text to show the steps involved in taking the temperature of a liquid in a laboratory. She
    6·1 answer
  • What is the difference between the new and open commands on the file menu
    12·1 answer
  • Which of the following allowed Temple Grandin to design more humane means of slaughtering cattle? she treated the cattle as inca
    5·2 answers
  • REEEEEEE I STILL NEED MORE AESTHETIC USERNAMES TO GO OFF OF PWEASE HELP IMA HAVE A PANIC ATTACK!!!... next post ima do a vote :&
    13·1 answer
  • The entirety of a packet at one layer becoming the payload section at another layer is known as
    8·2 answers
  • _______ Originally , the art of maganing engines; in its modern and extended sense
    7·1 answer
  • Which phrases/sentence correctly describe the use of bitmap images?
    8·1 answer
  • The replacer parameter of the stringify method accepts a/an ______________ or an array.
    15·1 answer
  • Harry needs to make a presentation on packaging prototypes for a new product. Which presentation software elements can be use to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!