Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Nikolai99 avatar Nikolai99 0 Точки

моля помогнете задача 4 сграда 2 дена я мъча

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zad5
{
    class Program
    {
        static void Main(string[] args)
        {
            int floor = int.Parse(Console.ReadLine());
            int rooms = int.Parse(Console.ReadLine());
            for (int i = floor; i >= 1; i--)
            {
                for (int j = 0; j < rooms; j++)
                {
                    if (floor==i)
                    {
                        Console.Write($"L{i}{j}");
                    }
                    else if (floor % 2 == 0)
                    {
                        Console.Write($"O{i}{j}");
                    }
                    else if (floor % 2!=0)
                    {
                        Console.Write($"A{i}{j}");
                    }
                }
                Console.WriteLine();
                if (floor <= 0)
                {
                    break;
                }
            }
        }
    }
}

Тагове:
0
Programming Basics with C#
clipro avatar clipro 73 Точки

Последната проверка е else , а не else if. Добави интервал след всеки номер. Този break за какво е? Доколкото помня няма такова условие

0
Nikolai99 avatar Nikolai99 0 Точки

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zad5
{
    class Program
    {
        static void Main(string[] args)
        {
            int floor = int.Parse(Console.ReadLine());
            int rooms = int.Parse(Console.ReadLine());
            for (int i = floor; i >= 1; i--)
            {
                for (int j = 0; j < rooms; j++)
                {
                    if (floor==i)
                    {
                        Console.Write($"L{i}{j} ");
                    }
                    else if (floor % 2 == 0)
                    {
                        Console.Write($"O{i}{j} ");
                    }
                    else
                    {
                        Console.Write($"A{i}{j} ");
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

 

така пак не дава 100

 

0
21/11/2018 18:02:43
Nikolai99 avatar Nikolai99 0 Точки

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zad5
{
    class Program
    {
        static void Main(string[] args)
        {
            int floor = int.Parse(Console.ReadLine());
            int rooms = int.Parse(Console.ReadLine());
            for (int i = floor; i >= 1; i--)
            {
                for (int j = 0; j < rooms; j++)
                {
                    if (floor==i)
                    {
                        Console.Write($"L{i}{j} ");
                    }
                    else if (i % 2 == 0)
                    {
                        Console.Write($"O{i}{j} ");
                    }
                    else
                    {
                        Console.Write($"A{i}{j} ");
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

 

благодаря ти грешката ми е била във етажа

0
valio90 avatar valio90 6 Точки

using System;

namespace _7._7Building
{
    class Building
    {
        static void Main(string[] args)
        {
            int etaji = int.Parse(Console.ReadLine());
            int stai = int.Parse(Console.ReadLine());
            string vid = "";
            

            for (int i = etaji; i >= 1; i--)
            {
                
                for (int j = 0; j < stai; j++)
                {
                    if (etaji==i)
                    {
                        vid = "L";
                    }
                    else if (i%2==0)
                    {
                        vid = "O";
                    }
                    else
                    {
                        vid = "A";
                    }
                    Console.Write($"{vid}{i}{j} ");
                    
                }
                Console.WriteLine("");
            }
           
        }
    }
}

 

0
The_assassin avatar The_assassin 158 Точки

Ето ти още един вариант:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zad5
{
    class Program
    {
        static void Main(string[] args)
        {
            int floor = int.Parse(Console.ReadLine());
            int rooms = int.Parse(Console.ReadLine());
            char t = 'L';

                for (int i = floor; i > 0; i--)
                {
                    for (int j = 0; j < rooms; j++)
                    {
                        if (i < floor)
                        {
                            if (i % 2 == 0)
                            {
                              t = 'O';
                            } else {
                              t = 'A';
                        }
                    }
                Console.Write($"{t}{i}{j} ");
                }
                Console.Write("\n");
            }
        }
    }
}

 

0
Petya_koleva avatar Petya_koleva 104 Точки

Здравей! Това е твоят код направих промените, които са нужни и ти го пускам. https://pastebin.com/c0XHpyDG

КАто след всеки етаж трябва да има интервал и вмъкнах проверката за това, ако има само 1 етаж при нечетната проверка. Това е, надявам се да ме разбра.

0
22/11/2018 16:36:05
TeodoraTodorova1234 avatar TeodoraTodorova1234 4 Точки

Eто решението и на Java:

import java.util.Scanner;

class Building {
    public static void main (String[] args) {
            Scanner scan = new Scanner(System.in);
            int floors = Integer.parseInt(scan.nextLine());
            int rooms = Integer.parseInt(scan.nextLine());
            char t = 'L';

                for (int currentFloor = floors; currentFloor > 0; currentFloor--)
                {
                    for (int currentNum = 0; currentNum < rooms; currentNum++){
                        if (currentFloor < floors){
                            if (currentFloor % 2 == 0){
                              t = 'O';
                            } else {
                              t = 'A';
                        }
                    }
                System.out.printf("%c%d%d ",t, currentFloor, currentNum);
                
                }
                System.out.println(" ");
            }
        }
    }
 

0
nostrommo avatar nostrommo 2 Точки

Още едно решение на java

import java.util.Scanner;

public class Building {
    public static void main(String[] args) {
        Scanner input= new Scanner(System.in);

        int flour = Integer.parseInt(input.nextLine());
        int room = Integer.parseInt(input.nextLine());
        char symbol=' ';
        for (int i=flour;i>0;i--)
        {
            for (int j=0;j<room;j++)
            {
                if (i==flour)
                {
                    symbol='L';
                }
                else if(i%2==0)
                {
                    symbol='O';
                }
                else symbol='A';

                System.out.printf("%c%d%d ",symbol,i,j);
            }
            System.out.printf("%n");
        }

    }
}
0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.