2017 m. pagrindinės sesijos informacinių technologijų valstybinio brandos egzamino programavimo užduoties galimi sprendimai
|
|
- Adela Bennett
- 6 years ago
- Views:
Transcription
1 Pavyzdys A 2017 m. pagrindinės sesijos informacinių technologijų valstybinio brandos egzamino programavimo užduoties galimi sprendimai int konvertuojamas(int skaic, int id); char konvertuojamas2(int dal); int main() int a, b, laik; 1 programavimo užduotis. Šešioliktainiai skaičiai ifstream fd("u1.txt"); // Atidaromas duomenų failas. fd >> a >> b; ofstream fr("u1rez.txt"); // Atidaromas rezultatų failas. for(int i = 0; i < a; i++) for(int j = 0; j < b; j++) for(int z = 0; z < 3; z++) fd >> laik; fr << konvertuojamas2(konvertuojamas(laik, 0)) << konvertuojamas2(konvertuojamas(laik, 1)); if(z == 2 && j!= b - 1) fr << ";"; fr << endl; fd.close(); fr.close(); int konvertuojamas(int skaic, int id) // Funkcija, kuri konveruoja skaičius. int ats[3]; ats[0] = skaic / 16; ats[1] = skaic % 16; return ats[id]; char konvertuojamas2(int dal) // Funkcija, kuri konveruoja skaičius. char ats; if(dal == 0) ats = '0'; if(dal == 1) ats = '1'; if(dal == 2) ats = '2'; if(dal == 3) ats = '3'; if(dal == 4) ats = '4'; if(dal == 5) ats = '5'; if(dal == 6) ats = '6'; if(dal == 7) ats = '7'; if(dal == 8) ats = '8'; if(dal == 9) ats = '9'; if(dal == 10) ats = 'A'; if(dal == 11) ats = 'B'; if(dal == 12) ats = 'C'; if(dal == 13) ats = 'D'; if(dal == 14) ats = 'E'; if(dal == 15) ats = 'F'; return ats;
2 Pavyzdys B #include <iostream> void Konvertavimas(int skaicius,int & pirmas,int & antras); int main() ifstream fd("u1.txt"); ofstream fr("u1rez.txt"); int a, b, skaicius, pirmas, antras, kartai = 0; fd >> a >> b; for(int i = 0; i < a*b; i++) kartai++; for(int j = 0; j < 3; j++) fd >> skaicius; Konvertavimas(skaicius, pirmas, antras); if(pirmas >= 10 && pirmas <= 15)//Pirmo šešioliktainio skaičiaus skaitmens dydžio tikrinimas switch(pirmas) case 10: fr << "A"; break; case 11: fr << "B"; break; case 12: fr << "C"; break; case 13: fr << "D"; break; case 14: fr << "E"; break; case 15: fr << "F"; break; else fr << pirmas; if(antras >= 10 && antras <= 15)//Antro šešioliktainio skaičiaus skaitmens dydžio tikrinimas switch(antras) case 10: fr << "A"; break; case 11: fr << "B"; break; case 12: fr << "C"; break; case 13: fr << "D"; break; case 14: fr << "E"; break; case 15: fr << "F"; break; else fr << antras; if(kartai == b) fr << endl; kartai = 0; else fr << ";"; return 0; void Konvertavimas(int skaicius,int & pirmas,int & antras)//funkcija, konvertuojanti dešimtainį skaitmenį į šešioliktainį pirmas = skaicius / 16; antras = skaicius % 16;
3 Pavyzdys C program B09_1; type skaicius = record sk1, sk2: integer;//rezultatą saugantis skaitmeninis kintamasis r1, r2: char; //rezultatą saugantis raidžių kintamasis k1, k2: integer; function skaiciavimas(a: integer) : skaicius; // funkcija šešioliktainiui skaičiui rasti var p: skaicius; x: integer; with p do x:= a div 16; if x<10 then sk1:=x else inc(k1); if x=10 then r1:='a'; if x=11 then r1:='b'; if x=12 then r1:='c'; if x=13 then r1:='d'; if x=14 then r1:='e'; if x=15 then r1:='f'; x:= a mod 16; if x<10 then sk2:=x else inc(k2); if x=10 then r2:='a'; if x=11 then r2:='b'; if x=12 then r2:='c'; if x=13 then r2:='d'; if x=14 then r2:='e'; if x=15 then r2:='f'; skaiciavimas:=p; procedure uzduotis; // procedūra, kuri skaito iš failo, atlieka visus veiksmus ir užrašo į failą rezultatą var a, b, x, i, j, p: integer; // a, b - piešinio ilgis ir plotis f, ff: text; per: skaicius; assign(f, 'U1.txt'); reset(f); assign(ff, 'U1rez.txt'); rewrite(ff); readln(f, a, b); for x:= 1 to a do for i:= 1 to b do for j:= 1 to 3 do read(f, p); per:=skaiciavimas(p); if per.k1=0 then write(ff, per.sk1) else write(ff, per.r1);
4 if per.k2=0 then write(ff, per.sk2) else write(ff, per.r2); readln(f); if i<>b then write(ff, ';'); writeln(ff); close(f); close(ff); uzduotis; end.
5 Pavyzdys A 2 programavimo užduotis. Piešinys #include <iostream> struct staciakampiai int x; //viršutinio kairiojo kampo x koordinatė int y; //viršutinio kairiojo kampo y koordinatė int dx; //stačiakampio plotis int dy; //stačiakampio ilgis int R; //RGB pirma komponentė int G; //RGB antra komponentė int B; //RGB trečia komponentė ; void uzdejimas (int i, int A[], staciakampiai a[]); int ilgis (int n, staciakampiai a[]); int plotis (int n, staciakampiai a[]); int main() int n; staciakampiai a[100]; //duomenys apie stačiakampius ifstream fd ("U2.txt"); fd >> n; //skaitymo pradžia for (int i=0; i<n; i++) fd >> a[i].x >> a[i].y >> a[i].dx >> a[i].dy >> a[i].r >> a[i].g >> a[i].b; fd.close(); //skaitymo pabaiga int A[10000]; //kokio stačiakampio spalva yra kiekviename langelyje (-1 - balta), [] skliaustuose yra langelio koordinatė, nuo 0 iki 99 yra pirma eilutė, pridėjus 100 pereinama į sekančią. for (int i=0; i<10000; i++) A[i]=-1; for (int i=0; i<n; i++) //sudedami visi stačiakampiai uzdejimas(i,a,a); ofstream fr ("U2rez.txt"); fr << ilgis(n,a) << " " << plotis(n,a) << endl; //išvedimo pradžia for (int i=0; i<ilgis(n,a); i++) for (int j=0; j<plotis(n,a); j++) if (A[i*100+j]==-1) fr << 255 << " " << 255 << " " << 255 << endl; else fr << a[a[i*100+j]].r << " " << a[a[i*100+j]].g << " " << a[a[i*100+j]].b << endl; fr.close(); //išvedimo pabaiga return 0; void uzdejimas (int i, int A[], staciakampiai a[]) int virs=a[i].x+a[i].y*100; //viršūnės koordinatė for (int j=virs; j<virs+a[i].dx; j++) for (int z=0; z<a[i].dy; z++) A[j+z*100]=i; int ilgis (int n, staciakampiai a[]) //apskaičiuoja piešinio ilgį int max=a[0].y+a[0].dy; for (int i=1; i<n; i++) if (a[i].y+a[i].dy>max) max=a[i].y+a[i].dy;
6 return max; int plotis (int n, staciakampiai a[]) //apskaičiuoja piešinio plotį int max=a[0].x+a[0].dx; for (int i=1; i<n; i++) if (a[i].x+a[i].dx>max) max=a[i].x+a[i].dx; return max; Pavyzdys B struct st int x, y, x1, y1, r, g, b; // Struktūra duomenims apie stačiakampius. ; void spalva(int x, int y, st A[], int&r, int&g, int&b, int n); void skaityti(int&n, st A[], int&maxx, int&maxy); int main() ofstream out("u2rez.txt"); int r, g, b, n, maxx=0, maxy=0; st A[100]; skaityti(n, A, maxx, maxy); out << maxy << " " << maxx << endl; // Piešinio ilgis ir plotis. for(int i=0; i<maxy; i++) for(int j=0; j<maxx; j++) r=255; g=255; b=255; spalva(j, i, A, r, g, b, n); out << r << " " << g << " " << b << " " << endl; // Galutinės langelio spalvos radimas. out.close(); void spalva(int x, int y, st A[], int&r, int&g, int&b, int n) // Funkcija, dėliojanti stačiakampius. for(int i=0; i<n; i++) if(x>=a[i].x && x<=a[i].x1-1 && y>=a[i].y && y<=a[i].y1-1) r=a[i].r; g=a[i].g; b=a[i].b; void skaityti(int&n, st A[], int&maxx, int&maxy) // Funkcija, nuskaitanti duomenis iš failo. ifstream in("u2.txt"); in >> n; for(int i=0; i<n; i++) int dx, dy; in >> A[i].x >> A[i].y >> dx >> dy >> A[i].r >> A[i].g >> A[i].b; A[i].x1=dx+A[i].x;
7 if(a[i].x1>maxx) maxx=a[i].x1; A[i].y1=dy+A[i].y; if(a[i].y1>maxy) maxy=a[i].y1; in.close(); Pavyzdys C #include <iostream> #include <iomanip> struct _spalva int R=255; int G=255; int B=255; ; struct _staciakampis int x=100,dx; int y=100,dy; _spalva spalva; ; void skaitymas (int &n, _staciakampis staciakampis[]) ifstream f ("U2.txt"); f >> n; for (int i=0; i<n; i++) f >> staciakampis[i].x >> staciakampis[i].y; f >> staciakampis[i].dx >> staciakampis[i].dy; f >> staciakampis[i].spalva.r >> staciakampis[i].spalva.g >> staciakampis[i].spalva.b; f.close(); void pagrindo_didis (int &n, _staciakampis staciakampis[], int &x, int &y) for (int i=0; i<n; i++) if (staciakampis[i].x+staciakampis[i].dx > x) x=staciakampis[i].x+staciakampis[i].dx; if (staciakampis[i].y+staciakampis[i].dy > y) y=staciakampis[i].y+staciakampis[i].dy; int iterpti_staciakampi (_staciakampis stac, _spalva pagrindas[], int x, int y) for (int i=stac.y; i<stac.y+stac.dy; i++) for (int o=stac.x; o<stac.x+stac.dx; o++) pagrindas[i*x+o]=stac.spalva; void isvedimas (_spalva pagrindas[], int x, int y) ofstream o ("U2rez.txt"); o << y << " " << x << endl; for (int i=0; i<x*y; i++) o << pagrindas[i].r << " " << pagrindas[i].g << " " << pagrindas[i].b << endl; o.close(); int main()
8 int n; _staciakampis staciakampis[100]; _spalva pagrindas[10000]; int x=0,y=0; skaitymas(n,staciakampis); pagrindo_didis(n,staciakampis,x,y); for (int i=0;i<n;i++) iterpti_staciakampi(staciakampis[i],pagrindas,x,y); isvedimas(pagrindas,x,y); return 0;
Parengė ITMM Artūras Šakalys 1
2014.02.02 Parengė ITMM Artūras Šakalys 1 2014.02.02 Parengė ITMM Artūras Šakalys 2 Kaip suprantame masyvą? Pavyzdys: Peteliškių šeima; Gėlių laukas; 2014.02.02 Parengė ITMM Artūras Šakalys 3 Kaip suprasti
More informationC++ programavimo kalba
C++ programavimo kalba I/O biblioteka (2 paskaita) I/O operatoriai Išvedimo > #include using namespace std; void main() { float A = 18.236; cout
More informationC programavimo kalba. 3 paskaita (Sąlygos ir ciklo operatoriai, funkcija scanf() )
C programavimo kalba 3 paskaita (Sąlygos ir ciklo operatoriai, funkcija scanf() ) Sąlygos operatorius if - else Sąlygos operatoriai skirti perduoti programos vykdymą vienai ar kitai programos šakai. Operatorius
More informationSummary of basic C++-commands
Summary of basic C++-commands K. Vollmayr-Lee, O. Ippisch April 13, 2010 1 Compiling To compile a C++-program, you can use either g++ or c++. g++ -o executable_filename.out sourcefilename.cc c++ -o executable_filename.out
More informationMore About File Reading.
More About File Reading Prompts: Not Needed #include ... // code for opening the file input.dat 3-1 34 56 3 14 12 6 124 do cout > num); Reading the Entire
More informationA SHORT COURSE ON C++
Introduction to A SHORT COURSE ON School of Mathematics Semester 1 2008 Introduction to OUTLINE 1 INTRODUCTION TO 2 FLOW CONTROL AND FUNCTIONS If Else Looping Functions Cmath Library Prototyping Introduction
More informationTrumpai-ilga istorija
Įvadas į Web Services Kas yra Web Service? Kas ką žino??? 70-ieji: Mainframe Trumpai-ilga istorija 80-ieji: Client-Server Istorijos 90-ieji: Web 2000: SOA 2010: Cloud Computing Šaltinis: Sergejus Barinovas,
More information1. Which of the following best describes the situation after Line 1 has been executed?
Instructions: Submit your answers to these questions to the Curator as OQ3 by the posted due date and time. No late submissions will be accepted. For the next three questions, consider the following short
More informationKas yra masyvas? Skaičių masyvo A reikšmės: Elementų indeksai (numeriai): Užrašymas Turbo Paskaliu: A[1] A[2] A[3] A[4] A[5]
Masyvas 2013 1 Vienmatis masyvas Veiksmai su masyvo elementais: reikšmių priskyrimas ir išvedimas, paieška, rikiavimas. Masyvų perdavimas procedūros (funkcijos) parametrais. 2 Kas yra masyvas? Masyvu vadinamas
More information2008 m. valstybinio brandos egzamino užduotis
LIETUVOS RESPUBLIKOS ÐVIETIMO IR MOKSLO MINISTERIJA NACIONALINIS EGZAMINØ CENTRAS Mokinio (-ës) darbo vietos þymë Vardas, pavardë 2008 m. valstybinio brandos egzamino užduotis Pakartotinė sesija Egzamino
More informationReview Problems for Final Exam. 1. What is the output of the following program? #include <iostream> #include <string> using namespace std;
Review Problems for Final Exam 1. What is the output of the following program? int draw(int n); int n = 4; while (n>0) n = draw(n); int draw(int n) for(int i = 0; i < n; i++) cout
More informationFile I/O. File Names and Types. I/O Streams. Stream Extraction and Insertion. A file name should reflect its contents
File I/O 1 File Names and Types A file name should reflect its contents Payroll.dat Students.txt Grades.txt A file s extension indicates the kind of data the file holds.dat,.txt general program input or
More informationJAVA pagrindai Lek. Liudas Drejeris
JAVA pagrindai Lek. Liudas Drejeris Programa (1) Programa, tai eilė instrukcijų (vadinamų programiniais sakiniais), kurie vykdomi paeiliui, kol gaunamas norimas rezultatas. Programa (2) Programa (2) /*
More information3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)
Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.
More information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More information2012 m. valstybinio brandos egzamino uþduotis, pagrindinë sesija
1 iš 24 LIETUVOS RESPUBLIKOS ÐVIETIMO IR MOKSLO MINISTERIJA NACIONALINIS EGZAMINØ CENTRAS Kandidato (-ës) darbo vietos þymë 2012 m. valstybinio brandos egzamino uþduotis, pagrindinë sesija Egzamino trukmë
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationCOL 100. Minor 2 Exam - Practice
COL 100. Minor 2 Exam - Practice Name: Entry Number: Group: Notes: Total number of questions: 4. Max Marks: 20 All answers should be written on the question paper itself. The last two sheets in the question
More informationDELHI PUBLIC SCHOOL TAPI
Loops Chapter-1 There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed
More informationCS2141 Software Development using C/C++ Stream I/O
CS2141 Software Development using C/C++ Stream I/O iostream Two libraries can be used for input and output: stdio and iostream The iostream library is newer and better: It is object oriented It can make
More information2006 m. valstybinio brandos egzamino užduotis
LIETUVOS RESPUBLIKOS ÐVIETIMO IR MOKSLO MINISTERIJA NACIONALINIS EGZAMINØ CENTRAS 2006 m. valstybinio brandos egzamino užduotis 2006 m. gegužės 26 d. Egzamino trukmė 3 val. Testas 1 val. 25 min (85 min.)
More informationC++ Structures Programming Workshop 2 (CSCI 1061U)
C++ Structures Programming Workshop 2 (CSCI 1061U) Faisal Qureshi http://faculty.uoit.ca/qureshi University of Ontario Institute of Technology C++ struct struct keyword can be used to define new data types
More informationChapter 01 Arrays Prepared By: Dr. Murad Magableh 2013
Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 One Dimensional Q1: Write a program that declares two arrays of integers and fills them from the user. Then exchanges their values and display the
More informationWeek 3: File I/O and Formatting 3.7 Formatting Output
Week 3: File I/O and Formatting 3.7 Formatting Output Formatting: the way a value is printed: Gaddis: 3.7, 3.8, 5.11 CS 1428 Fall 2014 Jill Seaman spacing decimal points, fractional values, number of digits
More information4 4 4 RGB LED Cube kit Instruction Manual
4 4 4 RGB LED Cube kit Instruction Manual 1.How to solder the LED? There are 64 LEDs, every LED has 4 pins as per the below picture, The LEDs pin1 should be soldered to hole 1 on the pcb. Pin2 to pcb hole
More informationI/O Streams and Standard I/O Devices (cont d.)
Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore how to read data from the standard input device Learn how to use predefined
More informationCompanion C++ Examples
68 Appendix D Companion C++ Examples D.1 Introduction It is necessary to be multilingual in computer languages today. Since C++ is often used in the OOP literature it should be useful to have C++ versions
More informationC programavimo kalba. 5 paskaita (Funkcijos, masyvai)
C programavimo kalba 5 paskaita (Funkcijos, masyvai) Funkcijų pavyzdys // Skaičių lyginimo programa #include void pmax(int, int); /* prototipas */ int main() {int i, j; for (i = -10; i
More informationCS2255 HOMEWORK #1 Fall 2012
CS55 HOMEWORK #1 Fall 01 1.What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x >= y; a. 10 b. 7 c. The
More informationCMPS 221 Sample Final
Name: 1 CMPS 221 Sample Final 1. What is the purpose of having the parameter const int a[] as opposed to int a[] in a function declaration and definition? 2. What is the difference between cin.getline(str,
More informationChapter Two MIPS Arithmetic
Chapter Two MIPS Arithmetic Computer Organization Review Binary Representation Used for all data and instructions Fixed size values: 8, 16, 32, 64 Hexadecimal Sign extension Base and virtual machines.
More informationFile I/O Christian Schumacher, Info1 D-MAVT 2013
File I/O Christian Schumacher, chschuma@inf.ethz.ch Info1 D-MAVT 2013 Input and Output in C++ Stream objects Formatted output Writing and reading files References General Remarks I/O operations are essential
More informationReview Questions II KEY
CS 102 / ECE 206 Spring 2011 Review Questions II KEY The following review questions are similar to the kinds of questions you will be expected to answer on Exam II (April 7), which will focus on LCR, chs.
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationET 181. Purpose: The purpose of this lab is to become familiar with using arrays in C++.
Lab: 8 TA: Bob Setlock ET 181 Purpose: The purpose of this lab is to become familiar with using arrays in C++. Perpetual Note: I suggest opening the following two files in their own windows for reference:
More information[CSE10200] Programming Basis ( 프로그래밍기초 ) Chapter 9. Seungkyu Lee. Assistant Professor, Dept. of Computer Engineering Kyung Hee University
[CSE10200] Programming Basis ( 프로그래밍기초 ) Chapter 9 Seungkyu Lee Assistant Professor, Dept. of Computer Engineering Kyung Hee University CHAPTER 9 Pointers #1~2 Pointer int main () { int a; int b; int c;
More information1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?
Exercises with solutions. 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? #include b) What using statement do you always put at the top of
More informationI SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK a) What is the difference between Hardware and Software? Give one example for each.
I SEMESTER EXAM : : XI :COMPUTER SCIENCE : MAX MARK 70. a) What is the difference between Hardware and Software? Give one example for each. b) Give two differences between primary and secondary memory.
More informationLecture 4. 1 Statements: 2 Getting Started with C++: LESSON FOUR
1 Statements: A statement in a computer carries out some action. There are three types of statements used in C++; they are expression statement, compound statement and control statement. Expression statement
More informationSimboliai ir simbolių eilutės 2 val. Standartinės procedūros ir funkcijos darbui su simbolių eilutėmis
T8 Simboliai ir simbolių eilutės 2 val. Standartinės procedūros ir funkcijos darbui su simbolių eilutėmis 1 Kintamasis, kurio tipas nurodomas žodžiu char, skirtas simboliui saugoti. var a, b : char; Su
More informationCOP 3502 (Computer Science I) Test #1 Date: 9/13/2013. First Name:, Last Name:
COP 3502 (Computer Science I) Test #1 Date: 9/13/2013 First Name:, Last Name: Questions 1-3 concern the following set of #defines and struct definitions: #define NAMESIZE 20 #define TEAMSIZE 100 typedef
More informationBEng (Hons) Electronic Engineering. Resit Examinations for / Semester 1
BEng (Hons) Electronic Engineering Cohort: BEE/10B/FT Resit Examinations for 2016-2017 / Semester 1 MODULE: Programming for Engineers MODULE CODE: PROG1114 Duration: 3 Hours Instructions to Candidates:
More informationCS 240 Data Structure Spring 2018 Exam I 03/01/2018
CS 240 Data Structure Spring 2018 Exam I 03/01/2018 This exam contains three section A) Code: (basic data type, pointer, ADT) a. Reading: Trace the code to predict the output of the code b. Filling: Fill
More informationInput and Output File (Files and Stream )
Input and Output File (Files and Stream ) BITE 1513 Computer Game Programming Week 14 Scope Describe the fundamentals of input & output files. Use data files for input & output purposes. Files Normally,
More informationChapter 10 RECORDS (Structs )
Chapter 10 RECORDS (Structs ) In Chapter 6 we learned that an array is set up to use multiple elements of the same data type. What if we want to have several different related types within one data structure
More informationOutline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples.
Outline Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples. 1 Arrays I Array One type of data structures. Consecutive group of memory locations
More informationArray. Array Declaration:
Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and
More informationName Section: M/W T/TH Number Definition Matching (8 Points)
Name Section: M/W T/TH Number Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Iteration Counter Event Counter Loop Abstract Step
More informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationCSCE 110 Dr. Amr Goneid Exercise Sheet (6): Exercises on Structs and Dynamic Lists
CSCE 110 Dr. Amr Goneid Exercise Sheet (6): Exercises on Structs and Dynamic Lists Exercises on Structs (Solutions) (a) Define a struct data type location with integer members row, column Define another
More informationSetting Justification
Setting Justification Formatted I/O 1 Justification - Justification refers to the alignment of data within a horizontal field. - The default justification in output fields is to the right, with padding
More informationEAS 230 Fall 2002 Section B
EAS 230 Fall 2002 Section B Exam #2 Name: Person Number: Instructions: ƒ Total points are 100, distributed as shown by [ ]. ƒ Duration of the Exam is 50 minutes. I ) State whether True or False [25] Indicate
More informationCMSC 202 Midterm Exam 1 Fall 2015
1. (15 points) There are six logic or syntax errors in the following program; find five of them. Circle each of the five errors you find and write the line number and correction in the space provided below.
More informationToday in CS162. External Files. What is an external file? How do we save data in a file? CS162 External Data Files 1
Today in CS162 External Files What is an external file? How do we save data in a file? CS162 External Data Files 1 External Files So far, all of our programs have used main memory to temporarily store
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationStrings and Stream I/O
Strings and Stream I/O C Strings In addition to the string class, C++ also supports old-style C strings In C, strings are stored as null-terminated character arrays str1 char * str1 = "What is your name?
More informationReading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary
Reading from and Writing to Files Section 3.12 & 13.1 & 13.5 11/3/08 CS150 Introduction to Computer Science 1 1 Files (3.12) Data stored in variables is temporary We will learn how to write programs that
More informationType Analysis. Type Checking vs. Type Inference
Type Analysis Is an operator applied to an incompatible operand? Type checking: Static: Check for type compatibility at compile time Dynamic: Check for type compatibility at run time Type analysis phase
More informationCS 1428 Review. CS 2308 :: Spring 2016 Molly O Neil
CS 1428 Review CS 2308 :: Spring 2016 Molly O Neil Structure of a C++ Program Hello world // This program prints a greeting to the screen #include using namespace std; int main() { cout
More informationInformation Science. No. For each question, choose one correct answer and write its symbol (A E) in the box.
For each question, choose one correct answer and write its symbol (A E) in the box. (A E) Q16. When compiling the program below, the name of which is prog.c, the following error is reported. Which program
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,
More informationCSCE Practice Midterm. Data Types
CSCE 2004 - Practice Midterm This midterm exam was given in class several years ago. Work each of the following questions on your own. Once you are done, check your answers. For any questions whose answers
More informationText File I/O. #include <iostream> #include <fstream> using namespace std; int main() {
Text File I/O We can use essentially the same techniques we ve been using to input from the keyboard and output to the screen and just apply them to files instead. If you want to prepare input data ahead,
More information#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }
1. (9 pts) Show what will be output by the cout s in this program. As in normal program execution, any update to a variable should affect the next statement. (Note: boolalpha simply causes Booleans to
More informationConcours Informatique Luxembourgeois 2012 Epreuve Finale (05/07/2012) Solutions
Concours Informatique Luxembourgeois 2012 Epreuve Finale (05/07/2012) Solutions Tâche I Marathon 50 points #include #include #include #include #include
More informationThe C++ Language. Output. Input and Output. Another type supplied by C++ Very complex, made up of several simple types.
The C++ Language Input and Output Output! Output is information generated by a program.! Frequently sent the screen or a file.! An output stream is used to send information. Another type supplied by C++
More informationGE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004
GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout
More informationWe will exclusively use streams for input and output of data. Intro Programming in C++
C++ Input/Output: Streams The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: 1 istream
More informationATLAS (Automatically Tuned Linear Algebra Software),
LAPACK library I Scientists have developed a large library of numerical routines for linear algebra. These routines comprise the LAPACK package that can be obtained from http://www.netlib.org/lapack/.
More informationCSci 1113 Midterm 2. Name: Student ID:
CSci 1113 Midterm 2 Name: Student ID: Instructions: Please pick and answer any 6 of the 8 problems for a total of 90 points. If you answer more than 6 problems, only the first 6 will be graded. The time
More informationIntroduction to C ++
Introduction to C ++ Thomas Branch tcb06@ic.ac.uk Imperial College Software Society October 18, 2012 1 / 48 Buy Software Soc. s Free Membership at https://www.imperialcollegeunion.org/shop/ club-society-project-products/software-products/436/
More informationIntroduction to Programming I COS1511 School of Computing Revision Notes
Introduction to Programming I COS1511 School of Computing Revision Notes UNISA 2018 1 Introduction Some key basic principles to remember: Apply the BODMAS rules of Mathematics for all calculations; The
More informationFundamentals of Programming Session 25
Fundamentals of Programming Session 25 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationProgramming Languages CRN Test 2 Version 1 CMSC 4023 Autumn 2013
1. Print your name on your scantron in the space labeled NAME. 2. Print CMSC 4023 in the space labeled SUBJECT. 3. Print the test number and version, T2/V1, in the space labeled TEST NO. 4. Print the date,
More informationPrinciples of Programming Languages Topic: Imperative Programming II
Principles of Programming Languages Topic: Imperative Programming II Imperative Programming 1 Employee.c #include int find_over49(); void *malloc(); /*this makes these definitions and variables
More informationC++ Input/Output: Streams
C++ Input/Output: Streams Basic I/O 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams:
More informationBITG 1113: Files and Stream LECTURE 10
BITG 1113: Files and Stream LECTURE 10 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of input & output files. 2. Use data files for input & output
More informationLAB 5 Arithmetic Operations Simple Calculator
LAB 5 Arithmetic Operations Simple Calculator Objective: Practice arithmetic operation for the 80x86, such as add, subtract, multiple, divide, and mod. When dealing with the multiply, divide, and mod instructions
More informationBITG 1113: Array (Part 1) LECTURE 8
BITG 1113: Array (Part 1) LECTURE 8 1 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional (1 D)
More informationCSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1]
CSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1] LEARNING OBJECTIVES Upon completion, you should be able to: o define C++ text files o explain the benefits of using I/O file processing o explain
More informationProblem Solving: Storyboards for User Interaction
Topic 6 1. The while loop 2. Problem solving: hand-tracing 3. The for loop 4. The do loop 5. Processing input 6. Problem solving: storyboards 7. Common loop algorithms 8. Nested loops 9. Problem solving:
More informationCS103L SPRING 2018 UNIT 7: FILE I/O
CS103L SPRING 2018 UNIT 7: FILE I/O I/O STREAMS IN C++ I/O: short for input/ouput Older term from mainframe days for getting data into and out of your program C++ offers object oriented abstractions to
More informationC++ for Python Programmers
C++ for Python Programmers Adapted from a document by Rich Enbody & Bill Punch of Michigan State University Purpose of this document This document is a brief introduction to C++ for Python programmers
More informationPasirenkamojo modulio kūrybinio darbo atlikimas ir vertinimas
Pasirenkamojo modulio kūrybinio darbo atlikimas ir vertinimas Pasirenkamojo modulio kūrybinis darbas atliekamas keliais etapais: kūrybinio darbo temos (problemos / užduoties) pasirinkimas ir derinimas
More informationBITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18)
BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18) 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional
More informationESC101N: Fundamentals of Computing End-sem st semester
ESC101N: Fundamentals of Computing End-sem 2010-11 1st semester Instructor: Arnab Bhattacharya 8:00-11:00am, 15th November, 2010 Instructions 1. Please write your name, roll number and section below. 2.
More informationLambda functions. Zoltán Porkoláb: C++11/14 1
Lambda functions Terminology How it is compiled Capture by value and reference Mutable lambdas Use of this Init capture and generalized lambdas in C++14 Constexpr lambda and capture *this and C++17 Zoltán
More informationC++ Scope Resolution Operator ::
C++ Scope Resolution Operator :: C++The :: (scope resolution) operator is used to qualify hidden names so that you can still use them. You can use the unary scope operator if a namespace scope or global
More informationCSc Introduc/on to Compu/ng. Lecture 19 Edgardo Molina Fall 2011 City College of New York
CSc 10200 Introduc/on to Compu/ng Lecture 19 Edgardo Molina Fall 2011 City College of New York 18 Standard Device Files Logical file object: Stream that connects a file of logically related data to a program
More informationAs an example using arrays, let s write some code to get started with the Upthrust game. We can use a 2D array to represent the game board.
Array Example Upthrust Board As an example using arrays, let s write some code to get started with the Upthrust game. We can use a 2D array to represent the game board. First, note that the game board
More informationBLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI. Unit Wise Marks
BLUE PRINT SUBJECT: - COMPUTER SCIENCE(083) CLASS-XI Unit Wise Marks Unit No. Unit Name Marks 1. COMPUTER FUNDAMENTAL 10 2. PROGRAMMING METHODOLOGY 12 3. INTRODUCTION TO C++ 1. INTRODUCTION TO C++ 3 TOTAL
More informationChapter 6. I/O Streams as an Introduction to Objects and Classes. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 6 I/O Streams as an Introduction to Objects and Classes Overview 6.1 Streams and Basic File I/O 6.2 Tools for Stream I/O 6.3 Character I/O Slide 6-3 6.1 Streams and Basic File I/O I/O Streams I/O
More informationB.Sc. (Hons.) Computer Science I B.Sc. (Hons.) Electronics. (i) Runtime polymorphism and compile time polymorphism
[This question paper contains 6 printed pages.] Sr. No. of Question Paper 6065 D Your Roll No.... Unique Paper Code 2341011251305 N arne of the Course Name of the Paper Semester B.Sc. (Hons.) Computer
More informationGrades. Notes (by question) Score Num Students Approx Grade A 90s 7 A 80s 20 B 70s 9 C 60s 9 C
Grades Score Num Students Approx Grade 100 1 A 90s 7 A 80s 20 B 70s 9 C 60s 9 C Score Num Students Approx Grade 50s 7 C 40s 5 D 30s 3 D 20s 1 F Notes (by question) 1. Use exit to avoid long if-then-else
More informationPreview 8/28/2018. Review for COSC 120 (File Processing: Reading Data From a File)
Preview Relational operator If, if--if, nested if statement Logical operators Validating Inputs Compare two c-string Switch Statement Increment decrement operator While, Do-While, For Loop Break, Continue
More informationPaveikslėliai. Lekt. dr. Pijus Kasparaitis m. m. pavasario semestras.
Paveikslėliai Lekt. dr. Pijus Kasparaitis pkasparaitis@yahoo.com 2008-2009 m. m. pavasario semestras Klasė Image Priklauso paketui java.awt Abstrakti klasė paveldėta iš Object Tai visų grafinių paveikslėlių
More informationArrays. int Data [8] [0] [1] [2] [3] [4] [5] [6] [7]
Arrays Arrays deal with storage of data, which can be processed later. Arrays are a series of elements (variables) of the same type placed consecutively in memory that can be individually referenced by
More informationName Section: M/W T/TH Number Definition Matching (6 Points)
Name Section: M/W T/TH Number Definition Matching (6 Points) 1. (6 pts) Match the words with their definitions. Choose the best definition for each word. Event Counter Iteration Counter Loop Flow of Control
More informationCS240: Programming in C
CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor
More informationComputational Physics
Computational Physics numerical methods with C++ (and UNIX) 2018-19 Fernando Barao Instituto Superior Tecnico, Dep. Fisica email: fernando.barao@tecnico.ulisboa.pt Computational Physics 2018-19 (Phys Dep
More information