Programozási Alapismeretek Tóth Zsolt

Total Page:16

File Type:pdf, Size:1020Kb

Programozási Alapismeretek Tóth Zsolt Programozási alapismeretek Tóth Zsolt XML to PDF by RenderX XEP XSL-FO F ormatter, visit us at http://www.renderx.com/ Programozási alapismeretek Tóth Zsolt KÉSZÜLT A TÁMOP-4.1.2.A/1-11/1-2011-0096 TÉMÁJÚ, FELSŐFOKÚ SZAKKÉPZÉSEK FEJLESZTÉSE AZ NYME TTK-N PROJEKT KERETÉBEN Szerzői jog © 2012 Nyugat-magyarországi egyetem Ez a Mű a Creative Commons Nevezd meg! - Ne add el! - Így add tovább! 3.0 Unported Licenc feltételeinek megfelelően szabadon felhasználható [http://creativecommons.org/licenses/by-nc-sa/3.0/deed.hu]. XML to PDF by RenderX XEP XSL-FO F ormatter, visit us at http://www.renderx.com/ Tartalom 1. Bevezetés .................................................................................................................. 1 2. A Small Basic és a BASIC ........................................................................................... 3 3. Ismerkedés a Small Basic-kel és a programozással ............................................................ 4 A fejlesztőkörnyezet letöltése ................................................................................... 4 A fejlesztőkörnyezet felépítése és első programunk ...................................................... 4 Programszerkezet ................................................................................................... 6 Második programunk .............................................................................................. 6 4. A változók használata .................................................................................................. 8 Névbekérő program ................................................................................................ 8 A változókra vonatkozó szabályok ............................................................................ 9 „Számtároló” program ........................................................................................... 10 5. Feltételes elágazás ..................................................................................................... 11 Algoritmus-tervezés .............................................................................................. 11 Szorzóprogram feltételes elágazással ........................................................................ 12 6. Ugróutasítás ............................................................................................................. 14 Hatványprogram .................................................................................................. 15 7. Ciklusok .................................................................................................................. 16 Számlálós ciklus .................................................................................................. 16 Elöltesztelő ciklus ................................................................................................ 17 8. A grafikus ablak használata ......................................................................................... 19 Grafikus elemek megjelenítése ................................................................................ 20 Színek, vonalszélesség, négyzetrajzolás .................................................................... 21 Kitöltés .............................................................................................................. 22 Néhány grafikai alkalmazás .................................................................................... 23 Szövegmegjelenítés .............................................................................................. 25 9. Teknőcgrafika .......................................................................................................... 27 A kezdetek .......................................................................................................... 27 A teknőc használata .............................................................................................. 27 Összetettebb ábrák rajzolása teknőccel ..................................................................... 29 10. Szubrutinok ............................................................................................................ 32 Faktoriális kiszámítása szubrutinnal ......................................................................... 32 11. Tömbök ................................................................................................................. 33 Fordított sorrend tömbbel ....................................................................................... 33 Indexelés szöveggel .............................................................................................. 33 Többdimenziós tömbök ......................................................................................... 34 Tömbre épülő grafikus alkalmazás ........................................................................... 36 12. Események és vezérlők ............................................................................................. 38 Több esemény ..................................................................................................... 39 13. Flickr .................................................................................................................... 41 14. Játékprogramok Small Basic programozási nyelven ....................................................... 42 „Ütögetős” program .............................................................................................. 42 15. Kiegészítések a Small Basichez .................................................................................. 44 LitDev kiegészítés ................................................................................................ 44 Statisztikai alkalmazás LitDevvel ............................................................................ 44 Teaching kiegészítés ............................................................................................. 45 Data kiegészítés ................................................................................................... 45 Program importálása ............................................................................................. 46 16. Adatbázis-kezelés a Small Basicben ............................................................................ 47 Adatok szövegfájlban ............................................................................................ 47 Adatok Excel-táblában .......................................................................................... 47 17. Small Basic-példák .................................................................................................. 50 Helyesírás ........................................................................................................... 50 „Jóslat” .............................................................................................................. 51 Morzeábécé ......................................................................................................... 52 Kő-papír-olló játék egysoros programmal .................................................................. 53 iii XML to PDF by RenderX XEP XSL-FO F ormatter, visit us at http://www.renderx.com/ Programozási alapismeretek A „Zöld hullám” alkalmazás ................................................................................... 54 Koch-görbék ....................................................................................................... 55 Op-art rózsa ........................................................................................................ 58 Landolás ............................................................................................................. 59 „Retroléghajó” ..................................................................................................... 61 18. Néhány általános programozási feladat ........................................................................ 65 Keresés .............................................................................................................. 65 Minimális és maximális elem kiválasztása ......................................................... 65 Lineáris és bináris keresés .............................................................................. 65 Rendezés .................................................................................................... 68 Euler-problémák .................................................................................................. 73 1. probléma ................................................................................................. 73 2. probléma ................................................................................................. 74 3. probléma ................................................................................................. 74 4. probléma ................................................................................................. 75 5. probléma ................................................................................................. 76 6. probléma ................................................................................................. 76 7. probléma ................................................................................................. 77 Mátrixalgebra ...................................................................................................... 78 Statisztikai számítások ........................................................................................... 81 Animációs alapproblémák
Recommended publications
  • Baxedit Is an Editor for Programs in Basic Usable by Bax58c Compiler
    BaxEdit is an editor for programs in Basic usable by Bax58C compiler . © 2011 Pierre Houbert (21/11/2020) Page 1 SUMMARY Basic language ................................................................................ 3 The Menus .......................................................................................... 4 New ............................................................................................. 6 Open .................................................................................................. 9 Save .......................................................................................... 12 Print ............................................................................................. 13 Quit ................................................................................................. 15 Cut / Copy / Paste ..................................................................... 16 Find ......................................................................................... 17 Replace .......................................................................................... 18 Font .................................................................................................. 19 Colors ............................................................................................. 20 Language .............................................................................................. 21 About ............................................................................................. 22 File Explorer
    [Show full text]
  • Microsoft Small Basic
    Katolickie Gimnazjum i Liceum Ogólnokształcące im. Jana Pawła II w Łodzi Microsoft Small Basic Translated by Anna Wilk (klasa 2a 2009/2010) Wstęp Small Basic i programowanie Programowanie komputerowe jest zdefiniowane jako proces tworzenia oprogramowania komputerowego używającego języki programowania. Tylko jak mówimy i rozumiemy Anglików albo Hiszpana albo Francuzów, komputery mogą zrozumieć programy napisane w pewnych językach. To tzw. języki programowania. Na początku było niewiele takich języków, były proste i zrozumiałe. Z czasem oprogramowanie i komputery stały się bardziej skomplikowane i wyszukane, więc języki programowania również musiały ewaluować. W efekcie są to trudne do zrozumienia metody programowania, szczególnie dla początkujących. Small Basic przedstawia programowanie w przyjemny, niezwykle łatwy i ciekawy sposób, usuwa bariery, by każdy mógł wkroczyć w świat programowania. Small Basic - Środowisko Zacznijmy od przedstawienia interfejsu Small Basic’a i poruszania się w nim. Po pierwszym uruchomieniu zobaczycie właśnie takie okno: Obrazek 1 To jest Small Basic Środowisko, gdzie napiszemy nasze programy. Opiszemy każdy element zaznaczony numerem. 1. Edytor(1) to miejsce, w którym piszemy program. Otwierając przykładowy program lub poprzednio zapisany, pojawi się on w tym oknie. Możesz otworzyć i korzystać z kilku edytorów na raz. 2. Pasek narzędzi(2) nadaje komendy w edytorze. O różnych zadaniach nauczymy się później. 3. Powierchnia pod edytorem (3) to obszar na wszystkie okna edycji. Nasz pierwszy Program Już znasz podstawy, więc zacznijmy programować. Wpiszmy poniższą linijkę do edytora. TextWindow.WriteLine(„Hello World”) Jeżeli wszystko zostało wpisane poprawnie, to ujżymy coś takiego: Pierwszy Program Teraz, kiedy już napisaliśmy nasz pierwszy program, włączmy go. Możemy to zrobić klikajać na przycisk RUN w pasku narzędzi lub naciskając F5.
    [Show full text]
  • Microsoft Small Basic
    Microsoft Small Basic An introduction to Programming Chapter 1 An Introduction Small Basic and Programming Computer Programming is defined as the process of creating computer software using programming languages. Just like we speak and understand English or Spanish or French, computers can understand programs written in certain languages. These are called programming languages. In the beginning there were just a few programming languages and they were really easy to learn and comprehend. But as computers and software became more and more sophisticated, programming languages evolved fast, gathering more complex concepts along the way. As a result most modern programming languages and their concepts are pretty challenging to grasp by a beginner. This fact has started discouraging people from learning or attempting computer programming. Small Basic is a programming language that is designed to make programming extremely easy, approachable and fun for beginners. Small Basic’s intention is to bring down the barrier and serve as a stepping stone to the amazing world of computer programming. The Small Basic Environment Let us start with a quick introduction to the Small Basic Environment. When you first launch SmallBasic, you will see a window that looks like the following figure. Figure 1 - The Small Basic Environment This is the Small Basic Environment, where we’ll write and run our Small Basic programs. This environment has several distinct elements which are identified by numbers. The Editor, identified by [1] is where we will write our Small Basic programs. When you open a sample program or a previously saved program, it will show up on this editor.
    [Show full text]
  • BASIC Programming with Unix Introduction
    LinuxFocus article number 277 http://linuxfocus.org BASIC programming with Unix by John Perr <johnperr(at)Linuxfocus.org> Abstract: About the author: Developing with Linux or another Unix system in BASIC ? Why not ? Linux user since 1994, he is Various free solutions allows us to use the BASIC language to develop one of the French editors of interpreted or compiled applications. LinuxFocus. _________________ _________________ _________________ Translated to English by: Georges Tarbouriech <gt(at)Linuxfocus.org> Introduction Even if it appeared later than other languages on the computing scene, BASIC quickly became widespread on many non Unix systems as a replacement for the scripting languages natively found on Unix. This is probably the main reason why this language is rarely used by Unix people. Unix had a more powerful scripting language from the first day on. Like other scripting languages, BASIC is mostly an interpreted one and uses a rather simple syntax, without data types, apart from a distinction between strings and numbers. Historically, the name of the language comes from its simplicity and from the fact it allows to easily teach programming to students. Unfortunately, the lack of standardization lead to many different versions mostly incompatible with each other. We can even say there are as many versions as interpreters what makes BASIC hardly portable. Despite these drawbacks and many others that the "true programmers" will remind us, BASIC stays an option to be taken into account to quickly develop small programs. This has been especially true for many years because of the Integrated Development Environment found in Windows versions allowing graphical interface design in a few mouse clicks.
    [Show full text]
  • An ECMA-55 Minimal BASIC Compiler for X86-64 Linux®
    Computers 2014, 3, 69-116; doi:10.3390/computers3030069 OPEN ACCESS computers ISSN 2073-431X www.mdpi.com/journal/computers Article An ECMA-55 Minimal BASIC Compiler for x86-64 Linux® John Gatewood Ham Burapha University, Faculty of Informatics, 169 Bangsaen Road, Tambon Saensuk, Amphur Muang, Changwat Chonburi 20131, Thailand; E-mail: [email protected] Received: 24 July 2014; in revised form: 17 September 2014 / Accepted: 1 October 2014 / Published: 1 October 2014 Abstract: This paper describes a new non-optimizing compiler for the ECMA-55 Minimal BASIC language that generates x86-64 assembler code for use on the x86-64 Linux® [1] 3.x platform. The compiler was implemented in C99 and the generated assembly language is in the AT&T style and is for the GNU assembler. The generated code is stand-alone and does not require any shared libraries to run, since it makes system calls to the Linux® kernel directly. The floating point math uses the Single Instruction Multiple Data (SIMD) instructions and the compiler fully implements all of the floating point exception handling required by the ECMA-55 standard. This compiler is designed to be small, simple, and easy to understand for people who want to study a compiler that actually implements full error checking on floating point on x86-64 CPUs even if those people have little programming experience. The generated assembly code is also designed to be simple to read. Keywords: BASIC; compiler; AMD64; INTEL64; EM64T; x86-64; assembly 1. Introduction The Beginner’s All-purpose Symbolic Instruction Code (BASIC) language was invented by John G.
    [Show full text]
  • Introducción a Linux Equivalencias Windows En Linux Ivalencias
    No has iniciado sesión Discusión Contribuciones Crear una cuenta Acceder Página discusión Leer Editar Ver historial Buscar Introducción a Linux Equivalencias Windows en Linux Portada < Introducción a Linux Categorías de libros Equivalencias Windows en GNU/Linux es una lista de equivalencias, reemplazos y software Cam bios recientes Libro aleatorio análogo a Windows en GNU/Linux y viceversa. Ayuda Contenido [ocultar] Donaciones 1 Algunas diferencias entre los programas para Windows y GNU/Linux Comunidad 2 Redes y Conectividad Café 3 Trabajando con archivos Portal de la comunidad 4 Software de escritorio Subproyectos 5 Multimedia Recetario 5.1 Audio y reproductores de CD Wikichicos 5.2 Gráficos 5.3 Video y otros Imprimir/exportar 6 Ofimática/negocios Crear un libro 7 Juegos Descargar como PDF Versión para im primir 8 Programación y Desarrollo 9 Software para Servidores Herramientas 10 Científicos y Prog s Especiales 11 Otros Cambios relacionados 12 Enlaces externos Subir archivo 12.1 Notas Páginas especiales Enlace permanente Información de la Algunas diferencias entre los programas para Windows y y página Enlace corto GNU/Linux [ editar ] Citar esta página La mayoría de los programas de Windows son hechos con el principio de "Todo en uno" (cada Idiomas desarrollador agrega todo a su producto). De la misma forma, a este principio le llaman el Añadir enlaces "Estilo-Windows". Redes y Conectividad [ editar ] Descripción del programa, Windows GNU/Linux tareas ejecutadas Firefox (Iceweasel) Opera [NL] Internet Explorer Konqueror Netscape /
    [Show full text]
  • CCITE of Technological Education for Young People
    Creating fruitful and sustainable links between innovative organisations committed to the improvement CCITE of technological education for young people. The Centre for Innovation in Technological Education in Cambridge http://ccite.org Learning to code - with a purpose Part 5 Adrian Oldknow March 2015 [email protected] 22. More Robotics - OhBot: This is another UK invention currently being crowd-sourced. £80 buys you the top-of-the-range model with 6 motors to control: http://ohbot.weebly.com/ and http://www.crowdfunder.co.uk/ohbot-robot/backers/. There are some videos from BETT show 2015 at: http://ohbot.weebly.com/bett-videos.html. Matt Walker and Dan Warner set up a company called Loopy Computy in Stroud: http://www.loopycomputy.com/about.html. 23. More Robotics – Edison: This is another interesting crowd- sourced development, this time from Australia. Edison is an easy to use, cheap and LEGO compatible vehicles. I bought the `Edpack3 for £80’ deal from: http://meetedison.com/. The software and programming guides can be downloaded from http://meetedison.com/downloads/. One simple way (and unusual) way to program Edison is by making barcodes for it to read. Program can be written on many devices including Android and Apple portables and the designers have chosen to use the sound port as a way to send programs to Edison. The system was designed by Brenton O’Brien: http://meetedison.com/blog/meet-brenton-errr-edison/. There are just 3 buttons for on-board control to run, stop and learn programs. Programming: Edison is programmed using EdWare, an icon based graphical programming language.
    [Show full text]
  • Beginning Microsoft® Small Basic
    ® Beginning Microsoft Small Basic ® ® ® ™ Plus a Porting Guide to Microsoft Visual Basic , C# , and Java © PHILIP CONROD & LOU TYLEE, 2010 Kidware Software PO Box 701 Maple Valley, WA 98038 http://www.computerscienceforkids.com http://www.kidwaresoftware.com Copyright © 2010 by Philip Conrod & Lou Tylee. All rights reserved Kidware Software PO Box 701 Maple Valley, Washington 98038 1.425.413.1185 www.kidwaresoftware.com www.computerscienceforkids.com www.biblebytebooks.com All Rights Reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Printed in the United States of America ISBN-13: 978-1-937161-19-4 Book Cover Illustration by Kevin Brockschmidt Copy Editor: Stephanie Conrod This copy of the Beginning Microsoft Small Basic book and the associated software is licensed to a single user. Copies of the course are not to be distributed or provided to any other user. Multiple copy licenses are available for educational institutions. Please contact Kidware Software for school site license information. This guide was developed for the course, “Beginning Microsoft Small Basic,” produced by Kidware Software, Maple Valley, Washington. It is not intended to be a complete reference to the Small Basic language. Please consult the Microsoft website for detailed reference information. This guide refers to several software and hardware products by their trade names. These references are for informational purposes only and all trademarks are the property of their respective companies and owners. Microsoft, Visual Studio, Small Basic, Visual Basic, Visual J#, and Visual C#, IntelliSense, Word, Excel, MSDN, and Windows are all trademark products of the Microsoft Corporation.
    [Show full text]
  • Microsoft Small Basic
    Microsoft Small Basic Знакомство с программированием http://smallbasic.ru Перевод: Тарасова Анастасия ([email protected]) Глава 1 Введение Small Basic и Программирование Под словами «программирование для компьютера» понимается процесс создания программного обеспечения с использованием языков программирования. Подобно тому, как люди могут понимать английский или испанский или французский языки и разговаривать на них, компьютеры могут понимать программы, написанные на специальных языках. Эти языки и называются языками программирования. Изначально существовало всего несколько таких языков, которые были достаточно просты для изучения и понимания. Но по мере развития компьютеров и ПО языки программирования также начали быстро эволюционировать, попутно включая в себя более сложные понятия. В результате, большинство современных языков программирования и их понятия довольно сложны для начинающих разработчиков. Сложность восприятия у многих отбивает желание изучить или хотя бы попытаться понять компьютерное программирование. Язык программирования Small Basic предназначен для того, чтобы сделать обучение программированию предельно простым и доступным занятием для новичков, которое также может приносить удовольствие. Язык Small Basic разрабатывался с намерением снести барьер сложности и проложить дорогу в удивительный мир компьютерного программирования. Среда Разработки Small Basic Начнем с краткого введения в среду разработки Small Basic. Запуская SmallBasic.exe в первый раз, Вы увидите окно, которое выглядит следующим образом. Рисунок 1 – Среда разработки Small Basic Так выглядит среда Small Basic, где мы будем писать и запускать программы Small Basic. Среда разделена на несколько четко различимых между собой частей. В Редакторе, обозначаемом [1], мы будем писать программный код на языке Small Basic. Если вы откроете образец программы или ранее сохраненную программу, то она отобразится в этом редакторе. В нем вы можете изменять программу и сохранять ее для дальнейшего использования.
    [Show full text]
  • An Introduction to Microsoft Small Basic
    AN INTRODUCTION TO MICROSOFT SMALL BASIC RUSTY KEELE UETN TECH SUMMIT 2019 INTRODUCTION TODAY’S PLAN • History lesson: BASIC language • What Small Basic is and isn’t • How to get Small Basic • A Demonstration • Resources for learning and teaching ABOUT ME • Work at UEN • Programming since 4th grade • BASIC (on Commodore 64) was my first programming language! A SHORT HISTORY OF BASIC BEGINNINGS AT DARTMOUTH • Early 1960s - 2 Math Professors • Wanted an easy language for non- science students • Beginner’s All-purpose Symbolic Instruction Code MICRO COMPUTERS AND MICRO-SOFT • 1975 – Gates & Allen’s first product • Built in or included with most home computers of the 1970s and 1980s TYPE-IN PROGRAMS • From magazines and books • 101 BASIC Computer Games • School text book examples: “Try It In BASIC” BASIC BASHING • GOTO and GOSUB created spaghetti code • Dijkstra’s infamous quote • "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC.” • The rise of structured programming: Pascal and C THE DECLINE OF BASIC • More powerful home computers • Graphical environments • Increase in commercial and free software “WHY JOHNNY CAN'T CODE” • No easy way for kids to get hooked on programming • Searched for an easy to use BASIC • …ended up buying a Commodore 64! • Issued a challenge to Microsoft VIJAYE RAJI • Microsoft employee • Read Brin’s article • Created a new version of BASIC – Small Basic WHAT IS MICROSOFT SMALL BASIC? GOALS OF MICROSOFT SMALL BASIC • For beginners • A real (but simple) language
    [Show full text]
  • Microsoft Small Basic
    Microsoft Small Basic A la découverte de la programmation Avant de commencer Le mot des traducteurs Ce document d’une soixantaine de pages est peut-être l’un de vos premiers pas dans le monde du développement logiciel. Vous devrez certainement lire d’autres ouvrages et écrire un certain nombre de programmes (petits et grands) pour vous sentir complètement à l’aise avec ce nouveau domaine. Arrivé à la fin de ce document, vous aurez réalisé des programmes intéressants, tel que un jeu de casse-briques ou bien encore un programme changeant aléatoirement votre fond d’écran. SmallBasic – A la découverte de la programmation est le titre original de ce document. Il a été traduit en français par une équipe de MSP – Microsoft Student Partners – français : Jean-François Boulière, Sylvain Bruyère, Sébastien Courtois, Thomas De Toledo, Pierre Lasvigne et Christopher Maneu. Nous espérons que la lecture de ce document vous donnera envie de continuer votre découverte du développement et de vous initier à de nouveaux langages. Bienvenue dans le merveilleux monde de la programmation ! L’équipe des traducteurs Chapitre 1 Introduction Small Basic et la programmation logicielle La programmation logicielle est définie comme le processus de création de logiciel informatique en utilisant des langages de programmation. De même que nous parlons et comprenons l’anglais, l’espagnol ou le français, les ordinateurs peuvent comprendre des programmes écrits dans certains langages. Ces derniers sont appelés langages de programmation. Au commencement, il n’y avait que quelques langages de programmation et ils étaient vraiment faciles à apprendre et à comprendre. Mais au fur et à mesure que les ordinateurs et les logiciels devinrent de plus en plus sophistiqués, les langages évoluèrent rapidement, rassemblant davantage de concepts complexes au fur et à mesure de cette évolution.
    [Show full text]
  • Bax58c Is a Program That Compiles Basic Programs to Generate Programs for the TI58C Emulator
    Bax58C is a program that compiles Basic programs to generate programs for the TI58C emulator. © 2011 Pierre Houbert (13/11/2020) Page 1 SUMMARY Presentation ................................................................ 4 The compilation ............................................................. 6 Using the program ............................................ 8 Basic language ........................................................... 10 • <étiquette > 11 • CALL ( statement ) 12 • CHAIN ( statement ) 13 • CLEAR ( statement ) 14 • CLS ( statement ) 15 • DIM ( statement ) 16 • DO ( statement ) 17 • END ( statement ) 18 • FOR ( statement ) 19 • GOSUB ( statement ) 20 • GOTO ( statement ) 21 • IF ( statement ) 22 • INPUT ( statement ) 23 • LET ( statement ) 24 • ON ( statement ) 25 • PRINT ( statement ) 26 • PRINT TAB ( statement ) 27 • PRINT USING ( statement ) 28 • REM ( statement ) 29 • RETURN ( statement ) 30 • SET ( statement ) 31 • SLEEP ( statement ) 32 • SOUND ( statement ) 33 • STOP ( statement ) 34 • SWAP ( statement ) 35 • ABS (...) (function) 36 • ASC (...) (function) 36 • ATN (...) (function) 36 • CHR (...) (function) 36 • COS (...) (function) 36 © 2011 Pierre Houbert (13/11/2020) Page 2 • EXP (...) (function) 36 • FRAC (...) (function) 36 • INT (...) (function) 36 • LOG (...) (function) 36 • RND(...) (function) 36 • SGN (...) (function) 36 • SIN (...) (function) 36 • SQR (...) (function) 36 • TAN (...) (function) 36 • INKEY ( variable ) 37 • DATE (...) (variable) 38 • TIME (...) (variable) 39 • PI (constant) 40 Languages
    [Show full text]