The second lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
What is Data Type?
Primitive Types in C#: Integer Types, Floating-Point Types, Decimal Type, Boolean Type, Character Types, Strings, Objects
Value Types and Reference Types
Variables. Using Variables: Declaring, Initializing, Assigning Value, Accessing Value
Literals: The Values of the Variables in the Source Code. Boolean Literals. Integer Literals. Floating-Point Literals, Decimal Literals, String Literals and Escaping Sequences
Exercises: Working with Primitive Types and Variables
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
The first lecture of the ACM Aleppo CPC training. The local contest of ICPC. This lecture will help you get started in programming contests word with the lower bound techniques. The lectures focus on the C++ programming language and the STL library to solve programming problems.
What is Data Type?
Primitive Types in C#: Integer Types, Floating-Point Types, Decimal Type, Boolean Type, Character Types, Strings, Objects
Value Types and Reference Types
Variables. Using Variables: Declaring, Initializing, Assigning Value, Accessing Value
Literals: The Values of the Variables in the Source Code. Boolean Literals. Integer Literals. Floating-Point Literals, Decimal Literals, String Literals and Escaping Sequences
Exercises: Working with Primitive Types and Variables
C Programming/Strings. A string in C is merely an array of characters. The length of a string is determined by a terminating null character: '-' . So, a string with the contents, say, "abc" has four characters: 'a' , 'b' , 'c' , and the terminating null character.
In this chapter we will cover the conditional statements in C#, which we can use to execute different actions depending on a given condition. We will explain the syntax of the conditional operators if and if-else with suitable examples and explain the practical application of the operator for selection switch-case.
In this chapter we will get familiar with the console as a tool for data input and output. We will explain what it is, when and how to use it, and how most programming languages access the console. We will get familiar with some of the features in C# for user interaction: reading text and numbers from the console and printing text and numbers. We will also examine the main streams for input-output operations Console.In, Console.Out and Console.Error, the Console and the usage of format strings for printing data in various formats.
45 Days C++ Programming Language Training in Ambalajatin batra
Are you looking for C++Programming Training In Ambala?
Now you search ends here... Batra Computer Centre provides you best C++ Programming Language Training in Ambala Cantt. We also proides you training in C, HTML, PHP, Web Designing, Web Development, SEO, SMO also.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
Abstract: Chances are you code in a language that's either descended from C, inspired by C, or run in an interpreter that itself is written in C. Still... do you actually know how to code in C? Despite its long-standing position as a sort of "lingua franca", an agreed-upon common language, more and more developers are putting together successful, satisfying careers, without ever learning this seminal language. But what if you have to call into C code from your favorite scripting language, or use APIs like OpenGL that are written to be called from C? Many developers find C very challenging, particularly its manual memory-management and other low-level concerns. In this session, we'll show you why you shouldn't be afraid of C, how you can use the skills you already have from the languages you code in today, and how to master structs, enums, typedefs, malloc(), free(), and the rest of C's sharp edges. Examples will be from the point-of-view of the C-skewing iPhone SDK, but will be designed to be broadly applicable and platform-agnostic.
Presentation with a brief history of C, C++ and their ancestors along with an introduction to latest version C++11 and futures such as C++17. The presentation covers applications that use C++, C++11 compilers such as LLVM/Clang, some of the new language features in C++11 and C++17 and examples of modern idioms such as the new form compressions, initializer lists, lambdas, compile time type identification, improved memory management and improved standard library (threads, math, random, chrono, etc). (less == more) || (more == more)
C Programming/Strings. A string in C is merely an array of characters. The length of a string is determined by a terminating null character: '-' . So, a string with the contents, say, "abc" has four characters: 'a' , 'b' , 'c' , and the terminating null character.
In this chapter we will cover the conditional statements in C#, which we can use to execute different actions depending on a given condition. We will explain the syntax of the conditional operators if and if-else with suitable examples and explain the practical application of the operator for selection switch-case.
In this chapter we will get familiar with the console as a tool for data input and output. We will explain what it is, when and how to use it, and how most programming languages access the console. We will get familiar with some of the features in C# for user interaction: reading text and numbers from the console and printing text and numbers. We will also examine the main streams for input-output operations Console.In, Console.Out and Console.Error, the Console and the usage of format strings for printing data in various formats.
45 Days C++ Programming Language Training in Ambalajatin batra
Are you looking for C++Programming Training In Ambala?
Now you search ends here... Batra Computer Centre provides you best C++ Programming Language Training in Ambala Cantt. We also proides you training in C, HTML, PHP, Web Designing, Web Development, SEO, SMO also.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
Abstract: Chances are you code in a language that's either descended from C, inspired by C, or run in an interpreter that itself is written in C. Still... do you actually know how to code in C? Despite its long-standing position as a sort of "lingua franca", an agreed-upon common language, more and more developers are putting together successful, satisfying careers, without ever learning this seminal language. But what if you have to call into C code from your favorite scripting language, or use APIs like OpenGL that are written to be called from C? Many developers find C very challenging, particularly its manual memory-management and other low-level concerns. In this session, we'll show you why you shouldn't be afraid of C, how you can use the skills you already have from the languages you code in today, and how to master structs, enums, typedefs, malloc(), free(), and the rest of C's sharp edges. Examples will be from the point-of-view of the C-skewing iPhone SDK, but will be designed to be broadly applicable and platform-agnostic.
Presentation with a brief history of C, C++ and their ancestors along with an introduction to latest version C++11 and futures such as C++17. The presentation covers applications that use C++, C++11 compilers such as LLVM/Clang, some of the new language features in C++11 and C++17 and examples of modern idioms such as the new form compressions, initializer lists, lambdas, compile time type identification, improved memory management and improved standard library (threads, math, random, chrono, etc). (less == more) || (more == more)
Visual programming (VP) refers to a method of programming that uses a graphical interface to create and modify code, rather than typing out code manually. Unlike traditional text-based programming, visual programming uses visual elements to represent code. Some graphical elements you can use when creating programs with VP include:
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
I am Baddie K. I am a C++ Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Queensland. I have been helping students with their homework for the past 9 years. I solve homework related to C++. Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Homework.
C++ Loops General Discussion of Loops A loop is a.docxhumphrieskalyn
C++ Loops
General Discussion of Loops
A loop is a programming construct that allows a group of statements, called the loop body, to be
executed zero or more times. For example, a loop might cause a group of statements to be executed
12 times.
A loop is controlled in part by the loop continuation condition. As long as the loop continuation
condition remains true, the loop will continue to execute. In order for a loop to stop, it must have a
terminating action, i.e. statement(s) in the loop body which when executed insure that the
continuation condition will eventually become false.
A loop control variable is a variable whose change may cause the continuation condition to
become false. A common error is to not initialize the control variable. To help ensure that the loop
does not become an infinite loop, always make sure to do the following three things with the LCV
(loop control variable):
1) Initialize the LCV, almost always done before the loop.
2) Test the LCV, this is done inside the continuation condition.
3) Update or change the LCV, inside the loop body.
There are three kinds of loops that are commonly available in programming languages.
1) The while loop executes an indefinite and possibly zero number of repetitions.
2) The do-while loop executes an indefinite number of times, but always at least once.
3) The for loop is convenient when the number of repetitions is known in advance.
C++ Loops
The above three loop types are available in C and C++, but the while loop is the most often used;
lets see some examples.
Example 1: A while loop that determines the number of digits in a positive integer, N. Assume that
N has previously been declared and given a value.
int Copy = N; // don’t want to destroy N!
DigitCount = 1; // all numbers have at least 1 digit
while ( Copy >= 10) // count the rest of the digits
{
++DigitCount; // found one more digit
Copy /= 10; // get rid of rightmost digit
}
When the loop finishes, DigitCount holds the number of digits in the integer N.
Example 2: A do-while loop that determines the number of digits in integer, N, same as above.
int Copy = N; // don’t destroy original N
DigitCount = 0; // do-while loop will increment this at least once
do
{
++DigitCount; // found one more digit
Copy /= 10; // get rid of rightmost digit
}
while ( Copy != 0); // count the rest of the digits. Note the ‘;’
A for loop could also be used to count digits, but let’s instead look at an example more suited to the
strong points of the for loop.
Example 3: A loop to print all of the upper case letters.
char Ch;
for ( Ch = ‘A’; Ch <= ‘Z’; ++Ch )
cout << Ch;
This loop is equivalent to the following while loop:
char Ch;
Ch = ‘A’;
while ( Ch <= ‘Z’ )
{
cout << Ch;
++Ch;
}
The following rules are used by C++ when executing ...
I am Arnold H. I am a C++ Programming Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Sheffield, UK. I have been helping students with their homework for the past 6 years. I solve homework related to C++ Programming.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Programming Homework.
Basics of python with suitable examples (data types, loops (if, else, elif, while, for) , functions and its types and a program in python used for ordering the numbers)
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
In this chapter we will get acquainted with the operators in Java and the actions they can perform on the different data types. We will explain the priorities of the operators and we will analyze the different types of operators, according to the count of the arguments they can take and the actions they can perform. In the second part we will examine the conversion of data types.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
3. Variables & Data types
• To define a variable: [TypeName] [VariableName];
• Integer data types:
Note: int data type is 2 byte signed on some compilers and 4 on other.
Type name Size Range
char 1 byte signed -128 to 127
unsigned char 1 byte unsigned 0 to 255
short 2 byte signed -32,768 to 32,767
unsigned short 2 byte unsigned 0 to 65,535
long 4 byte signed -2,147,483,648 to 2,147,483,647
unsigned long 4 byte unsigned 0 to 4,294,967,295
long long 8 byte signed
-9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
unsigned long long 8 byte unsigned 0 to 18,446,744,073,709,551,615
4. Variables & Data types
• char type is also used to represent alphabets.
• Floating point data types (Real values):
• Boolean data type (true or false state variable): bool its size is 1 byte.
Type name Size Range Precision
float 4 bytes ±1.18 x 10-38 to ±3.4 x 1038 6-9 significant digits, typically 7
double 8 bytes ±2.23 x 10-308 to ±1.80 x 10308 15-18 significant digits, typically 16
5. Flow control statements
• If statement.
• Switch statement.
• While loop statement.
• For loop statement.
• Break and continue.
6. Flow control: if statement
• Syntax: If (Conditional expression)
one expression or {expressions block}
else if (Conditional expression)
one expression or {expressions block}
else if (Conditional expression)
one expression or {expressions block}
.
.
.
else if (Conditional expression)
one expression or {expressions block}
else
one expression or {expressions block}
7. Flow control: switch statement
• Syntax: switch(integer expression)
{
case (case value):
[break];
case (case value):
[break];
case (case value):
[break];
default:
[break];
}
8. Flow control: switch statement
• Used over if statement if we have a lot of equal condition if
statement (it is much faster than if statement).
• Note: we can leave out the brake statement if we want some cases
to do the same statements.
9. Flow control: while loop statement
• Syntax: while (Conditional expression)
one expression or {expressions block}
• Anther form: do
one expression or {expressions block}
while (Conditional expression)
• Used when we don’t know how many times we will loop.
• Note: we can use it to do infant loop if the condition will never be
false (ex. 10>0 , true).
10. Flow control: for loop statement
• Syntax
for(loop initialization; loop condition; increment expression)
one expression or {expressions block}
• Used when we know exactly how many times we will loop.
• We can omit the loop initialization , loop condition or increment
expression if we want to.
• Note: we can use it to do infant loop if the loop condition will never
be false (ex. 10>0 , true) or if we leave out the loop condition .
11. Flow control: break & continue
• If we want to skip the running iteration of the loop, we can use the
continue statement.
• If we want to terminate all the work of the loop, we can use the
break statement.
12. IO methods
• In C++ if we want to output something on the screen, we can use
cout stream.
• If we want to get an input from what the user is typing on the
screen, we can use cin stream.
• In general, cin cout streams are slow in programing contests.
• To get faster IO methods you may use the C programing language
methods printf and scanf.
• Or you may put this statement before any cin or cout statement:
ios::sync_with_stdio (false);
• This statement turns off the synchronization between the C++ IO
and C IO, so once you use it you can’t use printf and scanf.
13. IO techniques
• If we have many number of test cases or you don’t know how many
test cases you will get and you want to read the test cases while
there is a test case to read (or until you reach the end of the file)
you can use this statement which read x while the input file still
have x in it: while(cin >> x)
• If we don’t know how many test cases but we know that the file end
with zero we may use this statement: while(cin >> x && x)
• If we know how many test cases we can put the number of test
cases in for loop.
14. Example 1: A. Choosing Teams
The Saratov State University Olympiad Programmers Training Center (SSU
OPTC) has n students. For each student you know the number of times
he/she has participated in the ACM ICPC world programming
championship. According to the ACM ICPC rules, each person can
participate in the world championship at most 5 times.
The head of the SSU OPTC is recently gathering teams to participate in
the world championship. Each team must consist of exactly three
people, at that, any person cannot be a member of two or more teams.
What maximum number of teams can the head make if he wants each
team to participate in the world championship with the same members
at least k times?
Solve at:
15. Example 1: A. Choosing Teams
Input:
The first line contains two integers, n and k (1 ≤ n ≤ 2000; 1 ≤ k ≤ 5). The
next line contains n integers: y1, y2, ..., yn (0 ≤ yi ≤ 5), where yi shows the
number of times the i-th person participated in the ACM ICPC world
championship.
Output:
Print a single number — the answer to the problem.
Solve at:
16. Example 1: A. Choosing Teams
1. #include <iostream>
2. using namespace std;
3. int main() {
4. ios::sync_with_stdio(false);
5. int teamscount = 0, invidualcount = 0, n, k, x;
6. cin >> n >> k;
7. for (int i = 0; i < n; i++) {
8. cin >> x;
9. if (k + x <= 5) {
10. invidualcount++;
11. if (invidualcount == 3) {
12. invidualcount = 0;
13. teamscount++;
14. }
15. }
16. }
17. cout << teamscount << endl;
18. return 0;
19.}
Solve at:
17. Example 2: B. Present from Lena
Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a
present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The
largest digit n should be located in the centre. The digits should decrease as they approach
the edges. For example, for n = 5 the handkerchief pattern should look like that:
0
0 1 0
0 1 2 1 0
0 1 2 3 2 1 0
0 1 2 3 4 3 2 1 0
0 1 2 3 4 5 4 3 2 1 0
0 1 2 3 4 3 2 1 0
0 1 2 3 2 1 0
0 1 2 1 0
0 1 0
0
Solve at:
18. Example 2: B. Present from Lena
Your task is to determine the way the handkerchief will look like by the
given n.
Input
The first line contains the single integer n (2 ≤ n ≤ 9).
Output
Print a picture for the given n. You should strictly observe the number of
spaces before the first digit on each line. Every two adjacent digits in the
same line should be separated by exactly one space. There should be no
spaces after the last digit at the end of each line.
Solve at:
19. Example 2: B. Present from Lena
1. #include <iostream>
2. using namespace std;
3. int main() {
4. ios::sync_with_stdio(false);
5. int n;
6. cin >> n;
7. for (int i = 0; i < 2*n + 1; i++){
8. int charcters = n;
9. if (n - i > 0)
10. charcters -= n - i;
11. else
12. charcters -= i - n;
13. int spaces = 2 * n + 1 - ( 2 *
charcters + 1);
Solve at:
14. for (int j = 0;j < spaces/2; j++){
15. cout << " ";
16. }
17. for (int j = 0;j < charcters;j++){
18. cout << j << " ";
19. }
20. for (int j =charcters;j >=0; j--){
21. cout << j;
22. if (j)
23. cout << " ";
24. }
25. cout << endl;
26. }
27. return 0;
28.}
20. IO techniques
• If we want to output new line between each two test cases we can
put endl at the end of each test case but if we don’t want to put
endl at the end we have one of this choices:
1. We can put if statement at the end of the test case to check if this
is not the last test case:
if(t < T-1) cout << endl; // Where T: Number of Test cases
2. If we don’t know the number of test cases we my put if statement
at the beginning of each one to assert if it is not the first one so
we must put a new line to separate it from the last test case:
if(t) cout << endl; // Where t: 0-based index of the current test
case
21. Arrays:
To define array in C++: array_type array_name[number of elements]
• Note that the number of element in this type of array must be
constant.
• To define a constant value you may use the key word const before
the variable declaration.
• Usually we define the big arrays (have more than 1 KB) in global
scope to avoid stack overflow.
• Usually we define the array to have a constant element size big
enough to have the maximum number of element that the user may
input and then use how many we want from it.
22. Arrays:
• In C++ there is an operator called sizeof() used to get the size of a
fixed size identifier (variable array pointer….) in bytes we can use it
to determine the size of the array in bytes.
• Also in the cstring library we have a function called memset which
take 3 parameters 1- the destination, 2- the values ,3- the size of the
destination.
• This function can be used to fill an array with zeros to initialize it
before we can use it:
int a[10000];
memset(a,0,sizeof(a));
23. Arrays:
• Arrays can be used in too many points in code to store block of
code to process (reveres, sort, transform…..) or to extract distinct
elements of input and a lot more….
24. Strings:
• Strings is a type that represent array of characters.
• There is two type of strings we can use:
1. The C style string which is a char array and we will not use it for
now.
2. The C++ style string which is an object of the class string exist in
the <string> library. We will use it or now cause it is much easier.
• We can define a string the same way we define any variable but first
of all we must include the string library.
• We can access any character in the string by its index like if the
string is a 0-based index char array.
25. Strings:
• We will talk a lot more on strings in the next lechers but for now we
will take a lot of examples.
26. Example 3: Minesweeper
Have you ever played Minesweeper? It’s a cute little game which comes within a certain
Operating System which name we can’t really remember. Well, the goal of the game is to find
where are all the mines within a M × N field. To help you, the game shows a number in a
square which tells you how many mines there are adjacent to that square. For instance,
supose the following 4 × 4 field with 2 mines (which are represented by an ‘*’ character):
*...
....
.*..
....
If we would represent the same field placing the hint numbers described above, we would
end up with:
*100
2210
1*10
1110
have already noticed, each square may have at most 8 adjacent squares
Solve at:
27. Example 3: Minesweeper
Input:
The input will consist of an arbitrary number of fields. The first line of each
field contains two integers n and m (0 < n, m ≤ 100) which stands for the
number of lines and columns of the field respectively. The next n lines contains
exactly m characters and represent the field. Each safe square is represented by
an ‘.’ character (without the quotes) and each mine square is represented by an
‘*’ character (also without the quotes). The first field line where n = m = 0
represents the end of input and should not be processed.
Output:
For each field, you must print the following message in a line alone: Field #x:
Where x stands for the number of the field (starting from 1). The next n lines
should contain the field with the ‘.’ characters replaced by the number of
adjacent mines to that square. There must be an empty line between field
outputs.
Solve at:
28. Example 4: Cakeminator
You are given a rectangular cake, represented as an r × c grid. Each cell
either has an evil strawberry, or is empty. For example, a 3 × 4 cake may
look as follows:
The cakeminator is going to eat the cake! Each time he eats, he chooses a
row or a column that does not contain any evil strawberries and contains
at least one cake cell that has not been
eaten before, and eats all the cake cells there.
He may decide to eat any number of times.
Please output the maximum number of cake
cells that the cakeminator can eat.
Solve at:
29. Example 4: Cakeminator
Input:
The first line contains two integers r and c (2 ≤ r, c ≤ 10), denoting the
number of rows and the number of columns of the cake. The next r lines
each contains c characters — the j-th character of the i-th line denotes
the content of the cell at row i and column j, and is either one of these:
'.' character denotes a cake cell with no evil strawberry;
'S' character denotes a cake cell with an evil strawberry.
Output:
Output the maximum number of cake cells that the cakeminator can eat.
Solve at:
30. Other Exercises
Try these good exercises and remember the more you exercise, the
better you will become ;).
• Codeforces A. Boy or Girl
• Codeforces A. Presents
• Codeforces B. Permutation