![jazzwok](/avatars/38563.jpg)
jazzwok
03.03.2020 •
Computers and Technology
Write a program roman which converts numbers from decimal notation into Roman numerals. roman takes a single argument, a string containing a non-negative integer, and prints its Roman numeral equivalent to standard output. g
Solved
Show answers
More tips
- H Health and Medicine How Much Does Abortion Cost? Expert Answers and Insights...
- S Sport How to Build Arm Muscles? Effective Exercises and Tips...
- H Health and Medicine When can it be said that a person has a normal pulse?...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
- F Food and Cooking How to Properly Cook Buckwheat?...
- F Food and Cooking How Many Grams Are In a Tablespoon?...
Answers on questions: Computers and Technology
- H History Which of these intellectual movements had the greatest impact on the attitudes leading to the french revolution? a.renaissance b.age of enlightenment c.scientific revolution...
- M Mathematics Will give brainliest if correct A student has grades 84, 91, 78, and 74. He will have one more test. If they are all weighted equally, what must he earn in order to average...
- E English Your school recently organised a ‘work experience day’, when students spent one day working in a shopping mall. Your teacher has asked you to write a report about the...
Ответ:
// Program is written in C++ programming language
/ Comments are used for explanatory purpose
// Program starts here
#include<bits/stdc++.h>
using namespace std;
//Declare a function named value to represent the symbols of Roman Numerals
int value(char xy)
{
if (xy == 'I') { return 1; }
if (xy == 'V') { return 5; }
if (xy == 'X') { return 10; }
if (xy == 'L') { return 50; }
if (xy == 'C') { return 100; }
if (xy == 'D') { return 500; }
if (xy == 'M') { return 1000; }
return -1;
}
// Convert to numbers , taking Variable named input as input
int Converted(string &input)
{
// Declare a variable to store the calculated output
int calc;
// Set to 0
calc = 0;
// Iterate through input from 0 to the last character
for (int i=0; i<input.length(); i++)
{
int check1 = value(input[i]);
if (i+1 < input.length())
{
int check12= value(input[i+1]);
// Comparing both values
if (check1>= check2)
{
calc+ =check1;
}
else
{
calc+ =check2 - check1;
i++;
}
}
else
{
calc+ =check1;
}
}
return calc;
}
// Main method starts here
int main()
{
// String input declaration
string inp;
cout<"Enter any valid Roman numeral";
cout << "Result is "
<< Converted(inp);
return 0;
}
Ответ:
answer: ".mp3 files are audio files, and .zip files are compressed so they take less space. by "unzipping" .zip files, whatever files were compressed will be accessible."
explanation: