www.fatihkabakci.com

Personal Website and Computer Science TUR EN

ASCII ILE DIKDORTGEN ALGORITMASI

Last update: 3/4/2012 11:25:00 PM

Yazan ve Cevaplayan:Fatih KABAKCI

Bu soru 19.12.2010 tarihinde KingLion_m adlı kullanıcı tarafından sorulan bir sorudur.

Gelen Soru: Arkadaşlar bu programı Microsoft Visual Studio 2008 de nasıl yazabilirim?
Soru: Kendisine gönderilen 4 adet koordinat değerine göre (x1,x2,y1,y2) ekranın belirtilen bölgesine çerçeve çizen fonksiyon, main() fonksiyonu ile beraber çiziniz.
(Köşeler için 187,188,200,201 nolu ASCII karakterlerini, yatay çizgi için 205 karakterini, dikey çizgi içinde 166 karakterini kullanabilirsiniz).
Kolay gelsin.

Verilen Cevap:

Ascii karakterleri ile bir cerceve cizmek istedigimizde,kurgulamak istedigimiz sekil bir dikdortgen olacaktır.Eger tüm kenarları eşit bir dikdörtgen tasarlar isek buna kare cerceve de diyebiliriz.Her halükarda çizmek istedigimiz seklin ortası boş olacaktır.Yani cercevenin sadece koseleri ekranda 'monte' edilmelidir.Sorunun standart C++ dili ile yazılmıs algoritmasını asagıda yayımlıyorum,siz cout çıktı akışlarının yerine visual C++ output metotlarından bir tanesi uzerinde yazabilirsiniz.
#include <iostream>

using std::cout;

int main() {

int i,j;
       const int boy=15;
       cout << (char)218; // cercevenin sol ust kosesi

       for(i=0;i<boy;i++) {
       for(j=0;j<boy;j++) {
       if(i>0 && j>0 && i<boy-1 && j<boy-1) // cercevenin icinin boş olma ozelligi
       cout << ' ';
       else if(i==0 && j==boy-1) // cercevenin sag ust kosesi
       cout << (char)191;
       else if(i==boy-1 && j==0) // cercevenin sol alt kosesi
       cout << (char)192;
       else if(i==boy-1 && j==boy-1) // cercevenin sag alt kosesi
       cout << (char)217;
       else if(j>0 && j<boy-1)  // cercevenin alt ve ust kenarlari
       cout << '-';
       else if(i>0 && i<boy-1) // cercevenin sol ve sag kenarlari
       cout << '|';
       }
       cout << '\n';
       }
Başarılar
There has been no comment yet

Name:


Question/Comment
   Please verify the image




The Topics in Computer Science

Search this site for





 

Software & Algorithms

icon

In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning.

Programming Languages

icon

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. It can be used to create programs to control the behavior of a machine. Java,C, C++,C#

Database

icon

A database is an organized collection of data. The data are typically organized to model aspects of reality in a way that supports processes requiring information.

Hardware

icon

Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, memory, cpu.

Web Technologies

icon

Web development is a broad term for the work involved in developing a web site for the Internet or an intranet. Html,Css,JavaScript,ASP.Net,PHP are one of the most popular technologies. J2EE,Spring Boot, Servlet, JSP,JSF, ASP

Mobile Technologies

icon

Mobile application development is the process by which application software is developed for low-power handheld devices, such as personal digital assistants, enterprise digital assistants or mobile phones. J2ME

Network

icon

A computer network or data network is a telecommunications network that allows computers to exchange data. In computer networks, networked computing devices pass data to each other along data connections.

Operating Systems

icon

An operating system is software that manages computer hardware and software resources and provides common services for computer programs. The OS is an essential component of the system software in a computer system. Linux,Windows

Computer Science

icon

Computer science is the scientific and practical approach to computation and its applications.A computer scientist specializes in the theory of computation and the design of computational systems.