Ditutup

game 2

I need you to develop some software for me. I would like this software to be developed using C or C++. The mission of this assignment is to realize a simple paragraph justifier. As shown in my coding demonstration, your program will keep reading lines of text image using getline(). After reading a paragraph, it adjusts all the lines into an instructed width, so that it can show the words evenly spread out and fit in a straight edge at both margins (similar to "align full" option in a Microsoft word document).

This can be relatively easily done as we are dealing with a mono-space font set (not a proportional font set) shown on a command-line-type console. As an example, consider a line containing 5 words and 30 characters altogether. If this line needs to be justified into a 40-character width, the remaining10 spaces needs to be spread out between the words. Assume that the first word of the next line has more than 9 characters, that is, the word in the next line cannot be placed in the tail of this line so as to consume the extra spaces.

In this case, 2 spaces are placed between the first 4 words, followed by 4 spaces prior to the last word (tail adjustment), or 3 spaces are placed between the first 4 words, followed by a space prior to the last word (even adjustment).

Assume we have five six letter words.

Just the total of the letters of the words amounts to 30.

If those six words are to be printed in a field width of 40.

We have 10 spaces to distribute.

Also assume that following the five six letter words is a word that has more than 9 characters. That is, the next word cannot be placed in the tail of that we are filling out. The demands of that word exceed the extra spaces.

With tail justification:

2 spaces are inserted between word1 and word2,

2 spaces are inserted between word2 and word3,

2 spaces are inserted between word3 and word4,

and 4 spaces are inserted at the tail between word4 and word5.

With even justification, fewer spaces are leftover for the slot between the last two words.

More spaces are used earlier in the line.

So the ten spaces will be distributed as follows:

3 spaces are inserted between word1 and word2,

3 spaces are inserted between word2 and word3,

2 spaces are inserted between word3 and word4,

and 2 spaces are inserted between word4 and word5.

The requirements of this assignment are:

program keeps reading lines of text until reading an empty line

program then reads a width for the read paragraph

program then justifies the paragraph based on tail adjustment

program then shows the result in a bounding box

program allows to adjust the paragraph by going back to 2

program ends when it reads 0 as a new width

Restriction: Do not use stringstream. Instead parse each line read into words. A word should be defined as a sequence of non-white space characters delimited by white-space before and after it. And, remember that getline does not read the new-line, So here is a hint: Use the length of the line read to determine when your parse has reached the end of the line. Also the functionality provided <cctype> will be helpful.

Hint: For the solution of this problem you will have to read all of your words into a vector of strings.

Extra points (2 points) will be considered for even adjustment implementation.

Here is a hint to realize this mission - lines of words, say vector<string> words, is a straightforward conversion as implemented in the previous assignment and posted lecture example. Now, user types some width for justification. Let this width be W. The mission is to fill i-words in one line of this W. Note i > 0, i.e., every line must have at least one word. The logic will be:

let { w1, w2, ..., wi } be a collection of words. Then, [url removed, login to view]() + [url removed, login to view]() + ... + [url removed, login to view]() is the total length of this collection

since we need at least one space between these i words, we need i - 1 spaces at least, and therefore, we need Wmin = [url removed, login to view]() + [url removed, login to view]() + ... + [url removed, login to view]() + (i - 1) characters, which must be less than or equal to W

your first loop must identify this i and Wmin by going through vector<string> words you created

in the second loop, you simply create a line by adding w1 through wi-1 by placing a space between the two consecutive words

before placing the last word wi, you need to place W - Wmin spaces because this number is the excess spaces to fill in for justification (tail adjustment)!

There is no miracle or hidden trick to deal with these [url removed, login to view] left-hand side of the next example shows tail adjustment while the right-hand side shows even adjustment:

Enter text, empty return will quit the input

> Every photo, every edit, every album now lives

> in your iCloud Photo Library, easily viewable

> and consistent on all your devices.

> Automatically. The all-new Photos app makes

> it simpler than ever to find and rediscover

> your favorite photos. And you can make every

> shot look even better immediately after you've

> taken it with powerful new editing tools.

>

> Enter the width of text: 25

|-------------------------|

|Every photo, every edit,|

|every album now lives in|

|your iCloud Photo|

|Library, easily viewable|

|and consistent on all|

|your devices.|

|Automatically. The|

|all-new Photos app makes|

|it simpler than ever to|

|find and rediscover your|

|favorite photos. And you|

|can make every shot look|

|even better immediately|

|after you've taken it|

|with powerful new editing|

|tools. |

|-------------------------|

Enter the width of text: 30

|------------------------------|

|very photo, every edit, every|

|album now lives in your iCloud|

|Photo Library, easily viewable|

|and consistent on all your|

|devices. Automatically. The|

|all-new Photos app makes it|

|simpler than ever to find and|

|rediscover your favorite|

|photos. And you can make every|

|shot look even better|

|immediately after you've taken|

|it with powerful new editing|

|tools. |

|------------------------------|

Enter the width of text: 0

Enter text, empty return will quit the input

> Every photo, every edit, every album now lives

> in your iCloud Photo Library, easily viewable

> and consistent on all your devices.

> Automatically. The all-new Photos app makes

> it simpler than ever to find and rediscover

> your favorite photos. And you can make every

> shot look even better immediately after you've

> taken it with powerful new editing tools.

>

> Enter the width of text: 25

|-------------------------|

|Every photo, every edit,|

|every album now lives in|

|your iCloud Photo|

|Library, easily viewable|

|and consistent on all|

|your devices.|

|Automatically. The|

|all-new Photos app makes|

|it simpler than ever to|

|find and rediscover your|

|favorite photos. And you|

|can make every shot look|

|even better immediately|

|after you've taken it|

|with powerful new editing|

|tools. |

|-------------------------|

Enter the width of text: 30

|------------------------------|

|Every photo, every edit, every|

|album now lives in your iCloud|

|Photo Library, easily viewable|

|and consistent on all your|

|devices. Automatically. The|

|all-new Photos app makes it|

|simpler than ever to find and|

|rediscover your favorite|

|photos. And you can make every|

|shot look even better|

|immediately after you've taken|

|it with powerful new editing|

|tools. |

|------------------------------|

Enter the width of text: 0

Kemahiran: Pengaturcaraan C, Pengaturcaraan C++, Kejuruteraan Perisian

Lihat lebih lanjut: get 10 for every email, get 10 for every email you, get 10 for every email you process a job invitation, get $10 for every, get $10 for every email, get $10 for every email you, get $10 for every email you process! (a job invitation), design two 2 different logos for separate entertainment businesses, design two (2) different logos for separate entertainment businesses, create psd candle labels x 10 for candle gifts for wedding baby shower etc, dice game time result code, solution problem unit commitment, flash game save result, give solution problem shopping cart empty adding item cart oscommerce, graph theory solution problem

Tentang Majikan:
( 0 ulasan ) United States

ID Projek: #15909942

23 pekerja bebas membida secara purata $130 untuk pekerjaan ini

vrcoder

Hi, offering to help implementing the paragraph justifier including even adjustment implementation. As usual, great attention to detail and helpful comments in code. Experience: hundreds of C/C++ projects on this sit Lagi

$50 USD dalam sehari
(282 Ulasan)
7.3
$160 USD dalam 3 hari
(308 Ulasan)
7.1
freelancerLatino

Hello, I love C and C++ since more than 20 years ago ... I should be a good option for this project... 100% projects done!... I bid for 2 days due to the christmass ...but I can do it in 1 day. Best regards!

$100 USD dalam 2 hari
(110 Ulasan)
7.1
hbxfnzwpf

I am very proficient in c and c++. I have 16 years c++ developing experience now, and have worked for more than 6 years. My work is online game developing, and mainly focus on client side, using c++ under windows envir Lagi

$100 USD dalam 2 hari
(133 Ulasan)
7.0
FullStackService

i am c/c++ expert and have full experience for 10 years. c++ language is my top skill. i can provide most quality and high speed. if you want to success, please contact me.

$155 USD dalam 3 hari
(17 Ulasan)
5.6
jpStar

- Algorithm And Programing o C/C++, Java, C#, VB, Object-C o Qt, MFC o HTML, CSS, PHP, NodeJS o WordPress, Ionic, Electron, Cordova, AnglarJS, TypeScript o Data Structure and Algorithm, Assignment o M Lagi

$155 USD dalam 3 hari
(10 Ulasan)
4.0
itwonder1

Hello... I can make your c/c++ game project I am highly interested to do your project. I believe that, I can do this work properly and in timely by your instruction. We can again discuss about the budget according Lagi

$100 USD dalam 3 hari
(13 Ulasan)
4.1
PATechnology

A proposal has not yet been provided

$61 USD dalam 2 hari
(22 Ulasan)
4.0
Mickelson

Hi Nice to meet you I read your requirements I developed exact project like word auto margin Don't waste time, I will send you source code right now You can review my profiles kind regards.

$100 USD dalam 3 hari
(13 Ulasan)
4.0
shubhamj1995

I am computer science engineer with good knowledge of C/C++ and data strucutres and I can get your work done fast. contact if you have nay query

$55 USD dalam 5 hari
(9 Ulasan)
2.5
tutorsonlinehub

Lets chat and discuss about the work and price. No need to pay anything upfront first check the work and if you happy with work then pay me. You can pay me lowest price. Thanks 12 Year Experience in C, C++ , JAVA Lagi

$55 USD dalam 3 hari
(5 Ulasan)
2.2
freelancerSolvit

Write a paragraph justifier in C. .........................................................................................................

$50 USD dalam 0 hari
(3 Ulasan)
2.4
sakshamkhanna

I have extensive experience in C/C++ programming and I am proficient in string manipulation and console based output formatting. Please discuss more details in chat

$45 USD dalam 2 hari
(1 Ulasan)
1.6
$250 USD dalam 3 hari
(1 Ulasan)
0.8
Natanaelrojo19

A proposal has not yet been provided

$66 USD dalam 5 hari
(0 Ulasan)
0.0
ssi599a5dc458c8b

Let’s chat and discuss about price and work. 12 years experience in same filed you will get 100% correct work. No need to pay upfront money first check work quality and if you satisfied then pay.

$30 USD dalam 3 hari
(0 Ulasan)
0.0
$155 USD dalam 3 hari
(0 Ulasan)
0.0
$35 USD dalam sehari
(0 Ulasan)
0.0
$250 USD dalam sehari
(0 Ulasan)
0.0
$277 USD dalam 20 hari
(0 Ulasan)
0.0