Premium Essay

C Practise

In:

Submitted By AshCool
Words 883
Pages 4
Практическая работа №1.
Работа с символьными строками Цель работы Получение практических навыков в работе с массивами и указателями языка C, обеспечение функциональной модульности

Темы для предварительного изучения Указатели в языке C. Представление строк. Функции и передача параметров. Постановка задачи По индивидуальному заданию создать функцию для обработки символьных строк. За образец брать библиотечные функции обработки строк языка C, но не применять их в своей функции. Предусмотреть обработку ошибок в задании параметров и особые случаи. Разработать два варианта заданной функции — используя традиционную обработку массивов и используя адресную арифметику. Индивидуальные задания
1. Функция Copies(s,s1,n) Назначение: копирование строки s в строку s1 n раз
2. Функция Words(s) Назначение: подсчет слов в строке s
3. Функция Concat(s1,s2) Назначение: конкатенация строк s1 и s2 (аналогичная библиотечная функция C — strcat)
4. Функция Parse(s,t) Назначение: разделение строки s на две части: до первого вхождения символа t и после него
5. Функция Center(s1,s2,l) Назначение: центрирование — размещение строки s1 в середине строки s2 длиной l
6. Функция Delete(s,n,l) Назначение: удаление из строки s подстроки, начиная с позиции n, длиной l (аналогичная библиотечная Функция есть в Pascal).
7. Функция Left(s,l) Назначение: выравнивание строки s по левому краю до длины l.
8. Функция Right(s,l) Назначение: выравнивание строки s по правому краю до длины l.
9. Функция Insert(s,s1,n) Назначение: вставка в строку s подстроки s1, начиная с позиции n (аналогичная библиотечная функция есть в Pascal).
10. Функция Reverse(s) Назначение: изменение порядка символов в строке s на противоположный.
11. Функция Pos(s,s1) Назначение: поиск первого вхождения

Similar Documents

Free Essay

It/218 Object Oriented Programming

...Object oriented programming refers to a method of programming in which individual objects, usually called "methods" and "functions", are created and used in junction with each other to perform a function. These objects are organized within the program through use of things called structures or classes. A class is something we use to create a blueprint of sorts for a assortment of variables and components. Similarly, a structure serves the same purpose. The only difference between a structure and a class is that a structure's members are public by default and a classes members are private by default. Another form of "blueprint" used by programmers is the data union. While a union is very primitive in comparison to a structure or class, it is a good tool to use to conserve memory in larger applications. A union uses the same memory block for multiple variables at different points. While two variables in a union cannot be accessed at the same time, a union is a good way to re-use blocks of memory that would normally be left void after a variable is finished with. Now that I have covered the basic points of classes, structures and unions, I will go into more detail of just how powerful a class or structure can be. In basic reference, a class is simply a blueprint to something we create instances of later in the program. This is a very vague statement however, because in object-oriented programming the class is the backbone of the program. It is what makes the...

Words: 813 - Pages: 4

Premium Essay

Private Fitness Inc. Case

...To: Rosemary Worth From: Re: misplaced trust on Kate Hoffman causing money loss issue Date: September 17, 2012 This memo is in response to your questions concerning money loss issue raised by Kate Hoffman and any related operating problems. After an in depth study of your company’s daily operation procedure and a situation that you are unable to step in a managerial role because of family responsibilities, I suggest you hire a new manager to take care of daily operation management, focus on 3-4 popular classes, shorten opening hours, and base commissions on performance. My suggestion is based on obtaining better management controls in the following three aspects. People Controls You trust Kate Hoffman so much that you let her take multiple tasks such as marketing, facility up-keeping, scheduling of appointments and record keeping. Kate was paid a salary plus a commission based on gross revenues just as other instructors. Kate might have thought that she did more work than other instructors and deserved more commission. When her expectation was not met, she lacked the motivation to handle multiple tasks and turned to an unethical way – stealing money from unrecorded revenue. If a new manager is hired, Kate can be released from administrative work and concentrate on her instructor job. Thus, further money loss can be avoided, and you can still keep the friendship between Kate and you as before. Furthermore, the newly hired manager can take place of the part time clerical...

Words: 910 - Pages: 4

Free Essay

Clothing

...Lab # 4 OVERLOADING Coding : using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 {//*********************************multiplication************************************ class A { public int multiply(int a,int b) { return a * b; } public double multiply(int a, double b) { return a * b; } public double multiply(double a, double b) { //1 argument type different OVERLOADING can be performed return a * b; } }//*********************************fraction************************************ #region fraction class fraction { int numerator, denominator; //field public void display() { Console.WriteLine(numerator + "/" + denominator); } public fraction() { numerator = 0; denominator = 1; } public fraction( int n, int d) { numerator = n; denominator = d; } public fraction(int n) { numerator = n; denominator = 1; } } #endregion //*********************************length************************************ #region length class length { int feet, inches; public void display() { ...

Words: 276 - Pages: 2

Premium Essay

Intro to Programming Unit 1 Research Assignment

...structured programming and data structuring. 2) SQL (Structured Query Language) designed by, Donald D. Chamberlin, and Raymond F. Boyce. The motivation behind this language was designed for managing data held in a relational database management system. ( RDBMS) 3) C, Designed by Dennis Ritchie. the motivation behind this language is structured programming and allows lexical variable scope and recursion. 4) Applesoft BASIC, developed by Marc McDonald, and Ric Weiland. The motivation with this language was it was designed to be backwards-compatible with integer BASIC and used the core of Microsoft’s 6502 BASIC implementation. 5) GRASS, Developed by Thomas A. DeFanti. GRASS is similar to BASIC in sytax, but added numerous instructions for specifying 2D object animation, including scaling, translation, rotation and color changes over time. 1980’s 1) BASICA, Designed by Thomas E. Kurtz. Designed to offer support for the graphics and sound hardware of the IBM PC line. 2) Turbo Pascal, developed by Borland, under Philippe Kahn’s leadership. This is a software development system that includes a compiler and an integrated development environment for the Pascal programming language. 3) C++, designed by Bjarne Stroustrup. This is a general purpose programming language that is free-form and compiled. It is regarded as an intermediate-level language, as it comprises both high-level and low-level language features. It provides imperative, object-oriented and...

Words: 677 - Pages: 3

Premium Essay

Reusability of Code

...Reusability of Code To be able to compare and contrast procedural programming modules and object-oriented programming, or OOP for short, we need to understand the two different styles. Procedural programming was the most commonly used programming language early on with a top-down model. This programming module places its attention on procedures or actions, which take place within the program. A few examples of procedural programming are FORTRAN and BASIC. OOP although has become the preferred method of use. OOP focuses on objects, which are self-contained unit containing date and data operations. When it comes to the reusability of codes OOP makes this task much easier. As procedural programming is a line-by-line programming style as if to be writing out simple instructions. OOP however allows the programmer to utilize inheritance. Inheritance gives the programmer the ability to create new classes, known as subclasses, based on an existing class, known as the superclass. This ability enables the programmer to utilize the data and methods of the original class or superclass. This whole process is where the programmer is able to utilize code that already was written saving them time and eliminating the opportunity for programming errors. Another benefit to OOP over procedural programming is security and the ability to hide code. Within OOP, the programmer is able to label certain data fields as private. Once these data fields are labeled as private, their data and methods...

Words: 621 - Pages: 3

Premium Essay

Let Us C - Yashwant Kanetkar.Pdf

...Let Us C Fifth Edition Yashavant P. Kanetkar Dedicated to baba Who couldn’t be here to see this day... About the Author Destiny drew Yashavant Kanetkar towards computers when the IT industry was just making a beginning in India. Having completed his education from VJTI Mumbai and IIT Kanpur in Mechanical Engineering he started his training company in Nagpur. Yashavant has a passion for writing and is an author of several books in C, C++, VC++, C#, .NET, DirectX and COM programming. He is a much sought after speaker on various technology subjects and is a regular columnist for Express Computers and Developer 2.0. His current affiliations include being a Director of KICIT, a training company and DCube Software Technologies, a software development company. In recognition to his contribution Microsoft awarded him the prestigious “Best .NET Technical Contributor” award recently. He can be reached at kanetkar@kicit.com. Preface to the Fifth Edition It is mid 2004. World has left behind the DOTCOM bust, 9/11 tragedy, the economic downturn, etc. and moved on. Countless Indians have relentlessly worked for close to two decades to successfully establish “India” as a software brand. At times I take secret pleasure in seeing that a book that I have been part of, has contributed in its own little way in shaping so many budding careers that have made the “India” brand acceptable. Computing and the way people use C for doing it keeps changing as years go by. So overwhelming...

Words: 46379 - Pages: 186

Free Essay

Cmu 213 Ppt

...Carnegie Mellon Course Overview 15-213 /18-213: Introduction to Computer Systems 1st Lecture, Jan. 14, 2014 Instructors: Seth Copen Goldstein, Anthony Rowe, Greg Kesden The course that gives CMU its “Zip”! 1 Carnegie Mellon Overview     Course theme Five realities How the course fits into the CS/ECE curriculum Logistics 2 Carnegie Mellon Course Theme: Abstraction Is Good But Don’t Forget Reality  Most CS and CE courses emphasize abstraction  Abstract data types  Asymptotic analysis  These abstractions have limits  Especially in the presence of bugs  Need to understand details of underlying implementations  Useful outcomes from taking 213  Become more effective programmers Able to find and eliminate bugs efficiently  Able to understand and tune for program performance  Prepare for later “systems” classes in CS & ECE  Compilers, Operating Systems, Networks, Computer Architecture, Embedded Systems, Storage Systems, etc.  3 Carnegie Mellon Great Reality #1: Ints are not Integers, Floats are not Reals  Example 1: Is x2 ≥ 0?  Float’s: Yes!  Int’s:   40000 * 40000  1600000000 50000 * 50000  ?? Source: xkcd.com/571 4 Carnegie Mellon Great Reality #1: Ints are not Integers, Floats are not Reals  Example 1: Is x2 ≥ 0?  Float’s: Yes!  Int’s:   40000 * 40000  1600000000 50000 * 50000  ?? Example 2: Is (x + y) + z = x + (y + z)?  Unsigned & Signed Int’s: Yes!  Float’s: ...

Words: 2285 - Pages: 10

Free Essay

Array List

...ArrayList Johnnie L. Bagley III PRG/420 October 09, 2013 Dr. Orenthio K. Goodwin ArrayList The differences between the Array and an ArrayList is a common question asked by beginners, just starting to code using Java. The Array and ArrayList are both used to store elements, which can be a primitive or an object in the case of ArrayList in Java. A main difference between the ArrayList and an Array in Java would be the static nature of the Array, but the ArrayList has a dynamic nature. Once an Array is created, programmers cannot change the size of it, but an ArrayList will be able to re-size itself at any time. There is one more notable difference between ArrayList and an Array (Paul, 2012). The Array is a core part of Java programming that has a special syntax and a semantics support within Java. An ArrayList is a part of the collection framework of popular classes, such as HashMap, Hashtable, and Vector. There are six more differences between Array and ArrayList which will be listed in numeral order: 1. First and Major difference between Array and ArrayList in Java would be that Array is a fixed length data structure, while ArrayList is a variable length collection class. 2. Another difference is that an Array cannot use Generics, due to it cannot store files, unlike the ArrayList that allows users to use Generics to ensure storage. 3. Programmers can compare the Array vs. ArrayList on how to calculate length of Array or size of an ArrayList. 4....

Words: 395 - Pages: 2

Free Essay

Mobile Applications

...PHP Tutorial - Learn PHP If you want to learn the basics of PHP, then you've come to the right place. The goal of this tutorial is to teach you the basics of PHP so that you can: • • • Customize PHP scripts that you download, so that they better fit your needs. Begin to understand the working model of PHP, so you may begin to design your own PHP projects. Give you a solid base in PHP, so as to make you more valuable in the eyes of future employers. PHP stands for PHP Hypertext Preprocessor. PHP - What is it? Taken directly from PHP's home, PHP.net, "PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly." This is generally a good definition of PHP. However, it does contain a lot of terms you may not be used to. Another way to think of PHP is a powerful, behind the scenes scripting language that your visitors won't see! When someone visits your PHP webpage, your web server processes the PHP code. It then sees which parts it needs to show to visitors(content and pictures) and hides the other stuff(file operations, math calculations, etc.) then translates your PHP into HTML. After the translation into HTML, it sends the webpage to your visitor's web browser. PHP - What's it do? It is also helpful to think of PHP in terms of what it can do for you. PHP will allow you to: ...

Words: 1556 - Pages: 7

Premium Essay

Comparison of C, C++, and C#

...Jason Latham Comparison of C, C++, and C# IADT Seattle The C family of languages has been a cornerstone in the programming field for years. So exactly what is the C family? It includes the C, C++ and C# (pronounced sharp) languages. Now that we know what they are, what are the differences between the three? Well, that is what will be discussed here. C is a minimalistic programming language because it could be compiled in a straightforward manner by a relatively simple compiler. C offers low-level access to memory via pointers and the ability to access specific hardware addresses. C generates only a few instructions of machine languages for each of its core language elements and does not require extensive run-time support. It can be concluded that C language is suitable for many systems-programming applications that had traditionally been implemented in assembly languages (Gabb, 2012). With its inherent low-level memory access and small run-time support, using C for embedded hardware systems is ideal. Many devices such as robots, machinery, and electronic tools are programmed utilizing its ability to access specific hardware addresses. However, as C is structured oriented programming language and focuses on the procedural programming paradigm, it is relatively hard to control the large-scale program. As C language has high level and machine level mixed programming capacity, it is used in most hardware related applications. It is very suitable for writing programs in embedded...

Words: 1038 - Pages: 5

Free Essay

Essay

...Minimum Shelf Problem Description At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program...

Words: 6793 - Pages: 28

Free Essay

Advantages of Phase Modulation

...docs@python.org Copyright c 2001, 2002, 2003 Python Software Foundation. All rights reserved. Copyright c 2000 BeOpen.com. All rights reserved. Copyright c 1995-2000 Corporation for National Research Initiatives. All rights reserved. Copyright c 1991-1995 Stichting Mathematisch Centrum. All rights reserved. See the end of this document for complete license and permissions information. Abstract Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for rapid application development, as well as for use as a scripting or glue language to connect existing components together. Python’s simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed. This reference manual describes the syntax and “core semantics” of the language. It is terse, but attempts to be exact and complete. The semantics of non-essential built-in object types and of the built-in functions and modules are described in the Python Library Reference. For an informal introduction to the language, see the Python Tutorial. For C or C++ programmers, two additional...

Words: 14272 - Pages: 58

Free Essay

Lab About Buffer Overflow Attack

...the length of your argument until you receive “Segmentation fault”. How long is the argument now? After disabling the buffer overflow protector using –fno-stack-protector, now we can overwrite into the stack without Abort. An argument of length 32 causes the segmentation fault. 20 (var) + 4 (var2)+ 4(input)+ 4(bptr) =32 5) a) In this step we created the script.pl file that needs arguments and the address to where it should jump. In our case we want to jump to hacked function. b) We run the gdb tool using “gdb a.out”. After that, using “(gdb) disassemble hacked” the assembly code of the function hacked was shown as below. The first shown address next to push is the address of the hacked function; which is “0x080484b7”. c) In the script.pl, we filled the argument of size 36 (size of string needed to reach the eip pointer) concatenated with function hacked address (which will come inside eip pointer), in reserved order as shown below: * 20 (var)...

Words: 482 - Pages: 2

Free Essay

Stuff1

...Starting Out with Programming Logic and Design, 3rd Edition By Tony Gaddis Python 3 Language Companion for Copyright © 2013 Pearson Education, Inc. Table of Contents Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Introduction 3 Introduction to Python 4 Input, Processing, and Output 10 Modularizing Programs with Functions 21 Decision Structures and Boolean Logic 30 Repetition Structures 39 Value-Returning Functions 48 Input Validation 60 Arrays (Lists) 62 Sorting and Searching 72 Files 77 Menu-Driven Programs 94 Text Processing 96 Recursion 100 Object-Oriented Programming 102 GUI Applications and Event-Driven Programming 111 Appendix A Introduction to IDLE Page 1 Introduction Welcome to the Python Language Companion for Starting Out with Programming Logic and Design, 2nd Edition, by Tony Gaddis. You can use this guide as a reference for the Python Programming Language as you work through the textbook. Each chapter in this guide corresponds to the same numbered chapter in the textbook. As you work through a chapter in the textbook, you can refer to the corresponding chapter in this guide to see how the chapter's topics are implemented in Python. In this book you will also find Python versions of many of the pseudocode programs that are presented in the textbook. Page 2 Chapter 1 Installing Python Introduction to Python Before you can run...

Words: 31767 - Pages: 128

Free Essay

Tech

...It is because DMA is an essential feature of all modern computers. It allows devices to transfer data without subjecting the CPU to a heavy overhead. Otherwise, the CPU would have to copy each piece of data from the source to the destination, making the CPU unavailable for other tasks. This situation is aggravated because access to I/O devices over a peripheral bus is generally slower than normal system RAM. With DMA, the CPU gets freed from this overhead and can do useful tasks during data transfer (though the CPU bus would be partly blocked by DMA). In the same way, a DMA engine in an embedded processor allows its processing element to issue a data transfer and carries on its own task while the data transfer is being performed. In another words, when data is transferred between an I/O device and memory in an application system using a microcontroller, the CPU specifies a transfer source address and a transfer destination address in sequence (1-byte units), if an ordinary access is made, and inputs and outputs data. This means that updating the address must be managed and that it takes a long time to transfer data by program processing. When a large amount of data must be processed, therefore, a long time is required. Consequently, the CPU cannot perform processing in time, especially when must process video data and audio data real-time or transfer data with a disk drive. DMA is a technique to speed up data transfer without using the CPU. DMA is executed by a...

Words: 301 - Pages: 2