Професионална програма
Loading...
+ Нов въпрос
Iv_Konov avatar Iv_Konov 383 Точки
Best Answer

Здравей,

готово - 100/100.

 

=======

 string command = Console.ReadLine(); // добавих вход за End of game

            while (command != "End of game")
            {
                int firstPlayerCard = int.Parse(command); // добавих вход за End of game
                int secondPlayerCard = int.Parse(Console.ReadLine());
                if (firstPlayerCard > secondPlayerCard)
                {
                    firstPlayerPoints += firstPlayerCard - secondPlayerCard; // firstPlayerPoints = firstPlayerCard - secondPlayerCard
                }
                else if (secondPlayerCard > firstPlayerCard)
                {
                    secondPlayerPoints += secondPlayerCard - firstPlayerCard;
                }
                else if (firstPlayerCard == secondPlayerCard)
                {
                    NumberWars = true;
                    firstPlayerCard = int.Parse(Console.ReadLine());
                    secondPlayerCard = int.Parse(Console.ReadLine());
                    if (firstPlayerCard > secondPlayerCard)
                    {
                        //firstPlayerPoints = firstPlayerCard - secondPlayerCard;  // тук не се сумира разликата в точките - просто се печели играта с точките до момента!
                        numberWarsWinner = firstPlayerName;
                        numberWarsWinnerPoints = firstPlayerPoints;
                        break;
                    }
                    else if (secondPlayerCard > firstPlayerCard)
                    {
                        //secondPlayerPoints = secondPlayerCard - firstPlayerCard; // тук не се сумира разликата в точките - просто се печели играта с точките до момента!
                        numberWarsWinner = SecondPlayerName;
                        numberWarsWinnerPoints = secondPlayerPoints;
                        break;
                    }
                }
                command = Console.ReadLine(); //firstPlayerCard = int.Parse(Console.ReadLine()) // добавих вход за End of game
                //secondPlayerCard = int.Parse(Console.ReadLine());
            }

=======

 

Поздрави,

Иван

1
09/04/2019 21:13:20
whitez avatar whitez 5 Точки

Благодаря !

1
Rocio58 avatar Rocio58 0 Точки

I am glad to read this article. [url=https://www.google.com]google[/url]

0
Rajaghere avatar Rajaghere 0 Точки

Get the Netflix Apk, Premium Cracked Version, for Android and IOS from our website. Watch Unlimited Movies/Shows in 4k for free.

0
Borislav_Vulkov avatar Borislav_Vulkov 54 Точки

Здравейте и от мен,
ето едно нестандартно решение. Гледайки количеството код не мисля, че е по-удачния начин за рашаване на задачата но ми беше интерсно да го опитам.
Накрадко използвам безкраен While цикъл, който го прекъсвам при възникването на команди "End of game" или "Number wars". Решението използва и два метода. Първия "Winner" определя името на победителя от всяко раздаване или рвъща "Number wars" ако точките са еднакви. Втория метод "CalculatePoints" изчислява точките които трябва да бъдат добавени към точките на победителя при разглежданото раздаване. 

=========

using System;

namespace NumberWars
{
    class NumberWars
    {
        static void Main()
        {
            string firstPlayer = Console.ReadLine();
            string secondPlayer = Console.ReadLine();

            int firstPlayerPoints = 0;
            int secondPlayerPoints = 0;

            int firstPoints = 0;
            int secondPoints = 0;

            string comand1 = string.Empty;
            string comand2 = string.Empty;
            string winner = string.Empty;

            while (true)
            {
                comand1 = Console.ReadLine();
                if (comand1 == "End of game")
                {
                    break;
                }
                else
                {
                    firstPoints = int.Parse(comand1);
                }

                comand2 = Console.ReadLine();
                if (comand2 == "End of game")
                {
                    break;
                }
                else
                {
                    secondPoints = int.Parse(comand2);
                }

                winner = Winner(firstPlayer, secondPlayer, firstPoints, secondPoints);

                if (winner == firstPlayer)
                {
                    firstPlayerPoints += CalculatePoints(firstPoints, secondPoints);
                }
                else if (winner == secondPlayer)
                {
                    secondPlayerPoints += CalculatePoints(firstPoints, secondPoints);
                }
                else
                {
                    firstPoints = int.Parse(Console.ReadLine());
                    secondPoints = int.Parse(Console.ReadLine());
                    winner = Winner(firstPlayer, secondPlayer, firstPoints, secondPoints);
                    Console.WriteLine("Number wars!");
                    if (winner == firstPlayer)
                    {
                        Console.WriteLine("{0} is winner with {1} points", firstPlayer, firstPlayerPoints);
                    }
                    else
                    {
                        Console.WriteLine("{0} is winner with {1} points", secondPlayer, secondPlayerPoints);
                    }
                    break;
                }
            }

            if (comand1 == "End of game" || comand2 == "End of game")
            {
                Console.WriteLine("{0} has {1} points", firstPlayer, firstPlayerPoints);
                Console.WriteLine("{0} has {1} points", secondPlayer, secondPlayerPoints);
            }
        }

        static string Winner(string firstPlayer, string secondPlayer, int firstPoints, int secondPoints)
        {
            if (firstPoints > secondPoints)
            {
                return firstPlayer;
            }
            else if (secondPoints > firstPoints)
            {
                return secondPlayer;
            }
            else
            {
                return "Number wars";
            }
        }

        static int CalculatePoints(int firstPoints, int secondPoints)
        {
            int Calculate = firstPoints - secondPoints;
            if (Calculate < 0)
            {
                Calculate *= -1;
            }
            return Calculate;
        }
    }
}
 

1
Laus1986 avatar Laus1986 10 Точки

I liked most of the games which gives the opertunity of making the money in simple way.But earning money from the casino games is not so easy task which can help anyone to earn the money through the trading in casino games with the best https://icasinoreviews.info/bank-transfer-casino-nz/ site steps which most of the people follow for making more money.

0
krum_43 avatar krum_43 411 Точки

Gambling is a vice.

0
Fednado avatar Fednado 2 Точки

С малък принос имам блог, който е отзивчив и забавен при програмиране за облекчаване на стреса: https://techbigs.com

0
alberttynzov avatar alberttynzov 1 Точки

Hello, did you know that canabis can give butter? Canabis oil treatment has become popular today! Medicine is always one step ahead, and according to this, doctors say that this oil can be added to food and treats many diseases! It also helps with sleep disorders and insomnia! On this site https://cbddiagnosis.com talk about how useful this oil can be! Are you afraid to try this oil? Today I’ll go and buy it, I want to try how it works!

0
Akinzccm avatar Akinzccm 0 Точки

I checked the website and it looks nice and responsive. I also wish I could get a blog design like this site.  Any contributions?

0
ebyfezol avatar ebyfezol 6 Точки

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work…

Best Regards,

office.com/setup 

www.office.com/setup OR office.com/setup

0
barcel44 avatar barcel44 0 Точки

Download Hotstar Mod APK latest version Free for Android and watch your favorite tv shows and movies all in one place for free! Excited to and  Watch Live TV, Crickets, Episodes on Premium Services without any Ads for Free. https://www.techsmarti.com/hotstar-mod-apk/

0
29/04/2020 22:44:13
krum_43 avatar krum_43 411 Точки

Здравей колега,

Ето едно кратко решение и от мен(50/100)

https://pastebin.com/rj0TtiMh

Не знам защо някои от тестовете гърмят с Runtime error.

0
30/04/2020 11:22:36
aimglo avatar aimglo 1 Точки

FIFA 21 PPSSPP ISO File Download With PS4 Camera English ... FIFA 2021 is the latest game from the series of FIFA games developed by EA Sports. ... FIFA 2021 is not yet officially released so this is the modified version.

0
aimglo avatar aimglo 1 Точки

Subway Surfers Online Read complete write up on Subway Surfers Online And Subway Surfers Unblocked, also enjoy your favourite arcade game online with its latest features on Subway Surfers Online and Unblocked You can now play your favourite Arcade game Subway Surfers online There is a piece of wonderful news for all Subway Surfers fan,
 

0
aimglo avatar aimglo 1 Точки

DareTechy
number one Bitcoin Vendor in Nigeria, always check out Early Pregnancy Sign for your pregnancy sign and treatment in other to stay healthy, Get the latest and trending facts on InstaFactSite Fastzipmusic is the right spot to get Latest Music and Videos update.

Be it Afro Pop, Hip Hop, Afro beats, Comedies, and many more.

We are committed to promoting music and artists who have made good songs and music around the world

0
tayyabiqbal929 avatar tayyabiqbal929 0 Точки

number one Bitcoin Vendor in Nigeria, always check out for your pregnancy sign and treatment in other to stay healthy, Get the App and trending facts on is the right spot to get Latest Music and Videos update.

0
19/09/2020 07:52:19
krum_43 avatar krum_43 411 Точки

Така и не разбрах защо сетваш точките на двамата играчи на 2.Освен това като е писал и Иван при равни карти не се начисляват точки.

0
GBWhatsapp avatar GBWhatsapp 6 Точки

Thanks for the information that you share with us, i really like you r content about this GB WhatsApp

0