When it comes to writing tests we often live in the here-and-now and consequently end up producing "write-only" tests. This session looks at what we need to consider if we want to create tests that our future selves and teammates will find valuable instead of becoming another burden on top of delivering the feature itself.
If there is one place that we find it easy to take shortcuts it's when writing tests. Whether we're under the cosh or have an overly-optimistic view of our ability to write self-documenting code, instead of creating tests that support the production code and development process we can find ourselves producing WTFs (Weak Test Functions). The net effect is often a viscous cycle that disparages, instead of encourages us.
In the past I've tried many different ways to try and short-circuit the test writing process, but have only come-up short every time. This session takes a look at why skimping on elements of the test structure, such as organisation, naming and scope only leads to pain and hardship in the long run. Along the way we'll uncover the truth behind common folklore, such as only having one assertion per test.
Presented at ACCU Oxford (14th September 2015)
Functional C++? As opposed to what — dysfunctional? Well, kind of, yeah. Sure, in C++ the principal unit of composition is called a function, but that doesn't mean it's a functional language. And the idea of restricting mutability of state gets a nod with const, but it's a nod not a hug. And the STL shows influences of functional programming, although it falls short of being compositional. And, yes, sure, C++11 has lambdas, but then again, these days, who doesn't? Lambda calculus was invented in the 1930s.
This talk looks at how to express functional programming ideas in (post)modern C++ in a way that can be considered idiomatic to C++, rather than trying to use the power of overloading and meta-programming to pretend C++ is Haskell or Lisp. In short, immutability beyond const and into shared and persistent data structures, concurrency beyond threading and locks, and thinking about functions as transformations and units of composition rather than actions.
When it comes to writing tests we often live in the here-and-now and consequently end up producing "write-only" tests. This session looks at what we need to consider if we want to create tests that our future selves and teammates will find valuable instead of becoming another burden on top of delivering the feature itself.
If there is one place that we find it easy to take shortcuts it's when writing tests. Whether we're under the cosh or have an overly-optimistic view of our ability to write self-documenting code, instead of creating tests that support the production code and development process we can find ourselves producing WTFs (Weak Test Functions). The net effect is often a viscous cycle that disparages, instead of encourages us.
In the past I've tried many different ways to try and short-circuit the test writing process, but have only come-up short every time. This session takes a look at why skimping on elements of the test structure, such as organisation, naming and scope only leads to pain and hardship in the long run. Along the way we'll uncover the truth behind common folklore, such as only having one assertion per test.
Presented at ACCU Oxford (14th September 2015)
Functional C++? As opposed to what — dysfunctional? Well, kind of, yeah. Sure, in C++ the principal unit of composition is called a function, but that doesn't mean it's a functional language. And the idea of restricting mutability of state gets a nod with const, but it's a nod not a hug. And the STL shows influences of functional programming, although it falls short of being compositional. And, yes, sure, C++11 has lambdas, but then again, these days, who doesn't? Lambda calculus was invented in the 1930s.
This talk looks at how to express functional programming ideas in (post)modern C++ in a way that can be considered idiomatic to C++, rather than trying to use the power of overloading and meta-programming to pretend C++ is Haskell or Lisp. In short, immutability beyond const and into shared and persistent data structures, concurrency beyond threading and locks, and thinking about functions as transformations and units of composition rather than actions.
a) Write the recursive function in C++ to sort a set of data using M.pdfnageswara1958
a) Write the recursive function in C++ to sort a set of data using Merge Sort
b) Given a set of data as below:
5 10 15 29 34 42 79 87
Ans:)
merge sort:
merge sort is a one of the sorting technicis a sorting technique which divides the array into 2 sub
arrays which have size 2 and merge adjacent pair. so that after first process you have n/2 array of
size 2. this process is repeated until only one array remaining of size n.
a)
ans)
Source code: C++ program
// Program that sorts an array using merge sort
# include
# include
const int MAX = 4 ;
class array
{
private :
int *arr ;
int size ;
int count ;
public :
array( ) ;
array ( int sz ) ;
void add ( int num ) ;
void display( ) ;
static void sort ( int *a, int sz ) ;
void merge ( array &a, array &b ) ;
~array( ) ;
} ;
// initializes data member
array :: array( )
{
count = size = 0 ;
arr = NULL ;
}
// initialises data member
array :: array( int sz )
{
count = 0 ;
size = sz ;
arr = new int[sz] ;
}
// adds a new element to the array
void array :: add ( int num )
{
if ( count < size )
{
arr[count] = num ;
count++ ;
}
else
cout << \"\ Array is full\" << endl ;
}
// displays elements in an array
void array :: display( )
{
for ( int i = 0 ; i < count ; i++ )
cout << arr[i] << \"\\t\" ;
cout << endl ;
}
// merges two arrays
void array :: merge ( array &a, array &b )
{
sort ( a.arr, a.size ) ;
sort ( b.arr, b.size ) ;
size = a.count + b.count ;
arr = new int[size] ;
int i, j, k ;
for ( i = j = k = 0 ; j < a.count || k < b.count ; )
{
if ( a.arr[j] <= b.arr[k] )
arr[i++] = a.arr[j++] ;
else
arr[i++] = b.arr[k++] ;
count++ ;
if ( j == a.count || k == b.count )
break ;
}
for ( ; j < a.count ; )
{
arr[i++] = a.arr[j++] ;
count++ ;
}
for ( ; k < b.count ; )
{
arr[i++] = b.arr[k++] ;
count++ ;
}
}
// sorts an array
void array :: sort ( int *a, int sz )
{
int temp ;
for ( int i = 0 ; i <= sz - 2 ; i++ )
{
for ( int j = i + 1 ; j <= sz - 1 ; j++ )
{
if ( a[i] > a[j] )
{
temp = a[i] ;
a[i] = a[j] ;
a[j] = temp ;
}
}
}
}
// deallocates memory
array :: ~array( )
{
delete arr ;
}
void main( )
{
array a ( MAX ) ;
clrscr();
a.add ( 29 ) ;
a.add ( 5) ;
a.add ( 10) ;
a.add ( 15 ) ;
cout << \"\ Merge sort.\ \" ;
cout << \"\ First array: \" << endl ;
a.display( ) ;
array b ( MAX ) ;
b.add ( 34 ) ;
b.add ( 87 ) ;
b.add ( 79 ) ;
b.add ( 42) ;
cout << \"\ Second array: \" << endl ;
b.display( ) ;
array c ;
c.merge ( a, b ) ;
cout << \"\ Array after sorting: \" << endl ;
c.display( ) ;
getch();
}
i)insert
// initializes data member
array :: array( )
{
count = size = 0 ;
arr = NULL ;
}
// initialises data member
array :: array( int sz )
{
count = 0 ;
size = sz ;
arr = new int[sz] ;
}
// adds a new element to the array
void array :: add ( int num )
{
if ( count < size )
{
arr[count] = num ;
count++ ;
}
else
cout << \"\ Array is full\" << endl ;
}
the above code is used to inset of data in array.
ii. Selection
// displays elements in an array
void array :: display( )
{
for ( int i = 0 ; i < count ; i++ )
cout << arr[i] << \"\\t\.
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
A close look at 15 problems one can find when reviewing C++ code.
Offers code examples.
Covers indexed loops, tainted data, copy and paste errors, problems with comparisons, exceptions, etc.
You can use static code analysis tools to make code review easier. Code analyzers find errors and potential vulnerabilities in code, while saving the developers' time and the companies' money.
Manual code review is expensive - a group of programmers get together regularly to review the code.
One can run static analysis tools regularly to find mistakes and vulnerabilities early.
Presented at DevWeek (25th March 2015)
These days, testing is considered a sexy topic for programmers. Who’d have thought it? But what makes for good unit tests (GUTs)? There’s more to effective unit testing than just knowing the assertion syntax of a testing framework.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What style of test partitioning is most common, and yet scales poorly and is ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and can scale as the codebase grows?
This session will address these questions and outline exactly what makes a good unit test.
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the ‘\\0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != \'\\0\'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != \'\\0\'; c++)
str2[c] = str1[c];
str2[c] = \'\\0\';
printf(\"\ Original String: %s\", str1);
printf(\"\ Copied String: %s\", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != \'\\0\'; i++) ;
for (j = 0; str2[j] != \'\\0\'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = \'\\0\';
printf(\"\ Concatenated String: %s\", str1);
}
int main()
{
char data1[20], data2[20];
pri.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019corehard_by
Xочу рассказать про разработку библиотеки ORM для SQLite3 на С++14 (https://github.com/fnc12/sqlite_orm). В докладе хочется поделиться своим опытом в попытке создать ORM с которой можно забыть про текстовые запросы и как это адаптируется в С++ при помощи шаблонов.
This presentation considers certain specific features of C++11 and additions to STL library (uniform initialization, new containers and methods, move semantics).
Presentation by Taras Protsiv (Software Engineer, GlobalLogic), Kyiv, delivered at GlobalLogic C++ TechTalk in Lviv, September 18, 2014.
More details -
http://www.globallogic.com.ua/press-releases/lviv-cpp-techtalk-coverage
Story of static code analyzer developmentAndrey Karpov
Greetings from the past: simple tools and bad standards. Regular expressions don’t work. What is inside modern static code analyzers on the PVS-Studio example. About machine learning. Learning vs Data Flow analysis.
Simulation rules are almost the same to what I coded using Python bu.pdfsnewfashion
Simulation rules are almost the same to what I coded using Python but with one interesting
addition a partial immunity (see details below). The main difference between the Python version
and R-version of the code would be the use of vectorization. You should use as little as possible
of loops. In fact, there should be just one loop for the days-count. If anyone tries to create the
exact copy of my Python code but in R, the grade will be quite low. Below are rules that should
help you building a simulation model:
1. We assume that there are N_population citizens in a population. N_population is an input
parameter. During development and testing you can have it small, but your code should be able
to handle a reasonably large value for population size.
2. Every citizen has a health state healthy, sick, dead (or you can code it as 0, 1, 2). When we
start, all citizens are alive and healthy
3. To start the pandemic, you randomly mark a small number of citizens as sick there can be a
parameter for the number of initially infected citizens. You can start with 1 or 2 initial sick cases.
4. One iteration is one day. During the day, every citizen can meet a random number (say
between 0 and 20 inclusive) of randomly selected citizens. You dont really need to control all
citizens as we are interested in meetings of sick people only. We dont care how many healthy
people meet each other.
5. Every sick citizen can stay sick and infectious for 10 days, hence you should have some
counter for each sick citizen. After 10 days a sick citizen becomes healthy and stops spreading
the virus
6. Obviously, dead citizens cannot become sick, they dont meet anyone and, as a result, cannot
infect anyone.
7. During the day every sick citizen has a probability to die (mortality rate) from the disease with
probability 0.5% (quite low probability).
8. If a sick citizen does not die, then they can meet other people as per the rule 4 above, and if
they meet a healthy person, that person might become sick too and start infecting other people
starting from the next day (that is an infection day is day 0 of their sickness). The probability for
a citizen of becoming sick (infection rate) after a contact is 30% (this is quite high).
9. (New rule!) After surviving the infection and getting healthy, the person becomes immune.
This is a partial immunity. It does not make the person invincible but reduces the chance of
infection in future meetings with sick people. Take the immunity coefficient as 0.1. That is, a
probability of being infected for immune person is ten times lower than for the person without an
immunity. The infection rate for the immune person is the original infection rate multiplied by
the immunity coefficient, e.g. (0.3*0.1).
For the test, you can set immunity coefficient equal 1, which means no benefits of immunity and
the result should be the same as in Python example I presented.
10. You should run this simulation for a number of days (iterations) and store each da.
Sergio and Malena were married for 10 years before Malena unexpected.pdfsnewfashion
Sergio and Malena were married for 10 years before Malena unexpectedly passed away in 2021.
Sergio has a qualifying child dependent, Tomas (age 6), who lived with him all year. Sergio pays
all the cost of maintaining the home for himself and Tomas. Sergio has not remarried. In 2021,
Sergio filed his tax return as married filing jointly. Provided Sergio does not remarry by
December 31 of the current tax year, what is Sergio's correct and most favorable filing status for
2022?
Which of the following taxpayers may file as a Qualifying surviving spouse for 2022?
Ling (53) is unmarried and pays 75% of the cost of maintaining a home for her father, Tao (79),
who had no taxable income and did not live with Ling. Tao is Ling's qualifying relative
dependent, and she will claim him on her tax return in 2022. What is Ling's correct and most
favorable filing status for 2022?
Which of the following statements regarding the "tiebreaker" rules for claiming benefits,
including the Earned Income Credit (EIC), is TRUE?
Ladonna and Gabe are divorced and have one child. Ladonna is the custodial parent. For 2022,
Ladonna signed Form 8332, Release/Revocation of Release of Claim to Exemption for Child by
Custodial Parent, and gave the child's exemption to Gabe. Assuming all other requirements are
met, which benefits may Ladonna claim for this dependent?
Freida is not married. Her son, Diego, lived with her all year. To claim the filing status of head
of household, Freida must:
Which taxpayer may file as head of household? (If the scenario states the dependent is a
qualifying child or qualifying relative, it means they have passed all the dependency
requirements.)
Terry and Sal divorced in 2019. During 2022, their son Nick lived with his mother, Terry,
Terry's mother (Andrea), and Terry's best friend (Vanna) from January 1 to November 1. During
that time, Nick visited Sal every other weekend for a total of 40 nights.
On November 2, Nick went to live with Sal for the rest of the year. After that time, Nick visited
Terry, Andrea, and Vanna every other weekend for a total of 16 nights.
Terry's adjusted gross income (AGI) was $33,100, Andrea's AGI was $21,500, Vanna's AGI was
$32,600, and Sal's AGI was $29,900.
Who has the superior claim to Nick's dependency?.
More Related Content
Similar to Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
a) Write the recursive function in C++ to sort a set of data using M.pdfnageswara1958
a) Write the recursive function in C++ to sort a set of data using Merge Sort
b) Given a set of data as below:
5 10 15 29 34 42 79 87
Ans:)
merge sort:
merge sort is a one of the sorting technicis a sorting technique which divides the array into 2 sub
arrays which have size 2 and merge adjacent pair. so that after first process you have n/2 array of
size 2. this process is repeated until only one array remaining of size n.
a)
ans)
Source code: C++ program
// Program that sorts an array using merge sort
# include
# include
const int MAX = 4 ;
class array
{
private :
int *arr ;
int size ;
int count ;
public :
array( ) ;
array ( int sz ) ;
void add ( int num ) ;
void display( ) ;
static void sort ( int *a, int sz ) ;
void merge ( array &a, array &b ) ;
~array( ) ;
} ;
// initializes data member
array :: array( )
{
count = size = 0 ;
arr = NULL ;
}
// initialises data member
array :: array( int sz )
{
count = 0 ;
size = sz ;
arr = new int[sz] ;
}
// adds a new element to the array
void array :: add ( int num )
{
if ( count < size )
{
arr[count] = num ;
count++ ;
}
else
cout << \"\ Array is full\" << endl ;
}
// displays elements in an array
void array :: display( )
{
for ( int i = 0 ; i < count ; i++ )
cout << arr[i] << \"\\t\" ;
cout << endl ;
}
// merges two arrays
void array :: merge ( array &a, array &b )
{
sort ( a.arr, a.size ) ;
sort ( b.arr, b.size ) ;
size = a.count + b.count ;
arr = new int[size] ;
int i, j, k ;
for ( i = j = k = 0 ; j < a.count || k < b.count ; )
{
if ( a.arr[j] <= b.arr[k] )
arr[i++] = a.arr[j++] ;
else
arr[i++] = b.arr[k++] ;
count++ ;
if ( j == a.count || k == b.count )
break ;
}
for ( ; j < a.count ; )
{
arr[i++] = a.arr[j++] ;
count++ ;
}
for ( ; k < b.count ; )
{
arr[i++] = b.arr[k++] ;
count++ ;
}
}
// sorts an array
void array :: sort ( int *a, int sz )
{
int temp ;
for ( int i = 0 ; i <= sz - 2 ; i++ )
{
for ( int j = i + 1 ; j <= sz - 1 ; j++ )
{
if ( a[i] > a[j] )
{
temp = a[i] ;
a[i] = a[j] ;
a[j] = temp ;
}
}
}
}
// deallocates memory
array :: ~array( )
{
delete arr ;
}
void main( )
{
array a ( MAX ) ;
clrscr();
a.add ( 29 ) ;
a.add ( 5) ;
a.add ( 10) ;
a.add ( 15 ) ;
cout << \"\ Merge sort.\ \" ;
cout << \"\ First array: \" << endl ;
a.display( ) ;
array b ( MAX ) ;
b.add ( 34 ) ;
b.add ( 87 ) ;
b.add ( 79 ) ;
b.add ( 42) ;
cout << \"\ Second array: \" << endl ;
b.display( ) ;
array c ;
c.merge ( a, b ) ;
cout << \"\ Array after sorting: \" << endl ;
c.display( ) ;
getch();
}
i)insert
// initializes data member
array :: array( )
{
count = size = 0 ;
arr = NULL ;
}
// initialises data member
array :: array( int sz )
{
count = 0 ;
size = sz ;
arr = new int[sz] ;
}
// adds a new element to the array
void array :: add ( int num )
{
if ( count < size )
{
arr[count] = num ;
count++ ;
}
else
cout << \"\ Array is full\" << endl ;
}
the above code is used to inset of data in array.
ii. Selection
// displays elements in an array
void array :: display( )
{
for ( int i = 0 ; i < count ; i++ )
cout << arr[i] << \"\\t\.
A scrupulous code review - 15 bugs in C++ codePVS-Studio LLC
A close look at 15 problems one can find when reviewing C++ code.
Offers code examples.
Covers indexed loops, tainted data, copy and paste errors, problems with comparisons, exceptions, etc.
You can use static code analysis tools to make code review easier. Code analyzers find errors and potential vulnerabilities in code, while saving the developers' time and the companies' money.
Manual code review is expensive - a group of programmers get together regularly to review the code.
One can run static analysis tools regularly to find mistakes and vulnerabilities early.
Presented at DevWeek (25th March 2015)
These days, testing is considered a sexy topic for programmers. Who’d have thought it? But what makes for good unit tests (GUTs)? There’s more to effective unit testing than just knowing the assertion syntax of a testing framework.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What style of test partitioning is most common, and yet scales poorly and is ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and can scale as the codebase grows?
This session will address these questions and outline exactly what makes a good unit test.
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
1sequences and sampling. Suppose we went to sample the x-axis from Xmin to Xmax using a
step size of step
A)Draw a picture of what is going on.
B) Write a expression for n the total number of samples involved (in terms of Xmin, Xmax and
step)
C) Write out the sequence of x-samples
D) Write a direct and general expression for xi that captures the sequence
E) Write a recursive expression for the sequence
F) Write a program to compute and store the x-samples over the range -5x5 using a step size of
0.1 do everything in main ()
2 . We talked about the following string functions that are available in C (as long as you include
string.h):
int strlen(char str[])
void strcpy(char str1[], char str2[])
void strcat(char str1[], str2[])
Write your own versions of these functions; for example: int paul_strlen(int char str[]). Hint: for
your version of the strlen function, start at the first character in the array and keep counting until
you find the ‘\\0’ character (use a while loop for this). Note: Use your version of the strlen
function in the strcpy and strcat functions.
9. We want to insert a number into an array.
(a) Formulate the problem mathematically with two sequences: x and y. (b) Write a function of
the form:
insertNumIntoArray(int n, int array[], int num, int index)
The function inserts num into the array at the specified index. The rest of the array then follows.
For example, if num = 9 and index = 3 and array = [7 2 8 8 3 1 2] then the function will produce:
array = [7 2 8 9 8 3 1 2]
Note: assume that array is properly dimensioned to have at least 1 extra space for storage.
10. Repeat #2 by for the delete operation; that is, we want to delete a single element (at a
specified index) from an array; for example, suppose index = 3 and array = [50 70 10 90 60 20],
then the result will be
array: [50 70 10 60 20]
11. Repeat #2 by for an insert operation where we are inserting several values into the array. The
function should be of the form:
int insertArrayIntoArray(int n, int inArray[],
int nInsert, int insertArray[], int outArray[], int index)
The dimension of outArray is returned (explicitly). For example:
inArrayarray: [7 2 8 6 3 9]
insertArray: [50 60 70]
index: 2
outArray: [7 2 50 60 70 8 6 3 9]
Assume that outArray is large enough to hold all n + nInsert values.
Solution
#include
//Simulates strlen() library function
int paul_strlen(char str[])
{
int l;
for(l = 0; str[l] != \'\\0\'; l++) ;
return l;
}
//Simulates strcpy() library function
void paul_strcpy(char str1[], char str2[])
{
int c;
for(c = 0; str1[c] != \'\\0\'; c++)
str2[c] = str1[c];
str2[c] = \'\\0\';
printf(\"\ Original String: %s\", str1);
printf(\"\ Copied String: %s\", str2);
}
//Simulates strcat() library function
void paul_strcat(char str1[], char str2[])
{
int i, j;
for(i = 0; str1[i] != \'\\0\'; i++) ;
for (j = 0; str2[j] != \'\\0\'; i++, j++)
{
str1[i] = str2[j];
}
str1[i] = \'\\0\';
printf(\"\ Concatenated String: %s\", str1);
}
int main()
{
char data1[20], data2[20];
pri.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
Статичный SQL в С++14. Евгений Захаров ➠ CoreHard Autumn 2019corehard_by
Xочу рассказать про разработку библиотеки ORM для SQLite3 на С++14 (https://github.com/fnc12/sqlite_orm). В докладе хочется поделиться своим опытом в попытке создать ORM с которой можно забыть про текстовые запросы и как это адаптируется в С++ при помощи шаблонов.
This presentation considers certain specific features of C++11 and additions to STL library (uniform initialization, new containers and methods, move semantics).
Presentation by Taras Protsiv (Software Engineer, GlobalLogic), Kyiv, delivered at GlobalLogic C++ TechTalk in Lviv, September 18, 2014.
More details -
http://www.globallogic.com.ua/press-releases/lviv-cpp-techtalk-coverage
Story of static code analyzer developmentAndrey Karpov
Greetings from the past: simple tools and bad standards. Regular expressions don’t work. What is inside modern static code analyzers on the PVS-Studio example. About machine learning. Learning vs Data Flow analysis.
Similar to Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf (20)
Simulation rules are almost the same to what I coded using Python bu.pdfsnewfashion
Simulation rules are almost the same to what I coded using Python but with one interesting
addition a partial immunity (see details below). The main difference between the Python version
and R-version of the code would be the use of vectorization. You should use as little as possible
of loops. In fact, there should be just one loop for the days-count. If anyone tries to create the
exact copy of my Python code but in R, the grade will be quite low. Below are rules that should
help you building a simulation model:
1. We assume that there are N_population citizens in a population. N_population is an input
parameter. During development and testing you can have it small, but your code should be able
to handle a reasonably large value for population size.
2. Every citizen has a health state healthy, sick, dead (or you can code it as 0, 1, 2). When we
start, all citizens are alive and healthy
3. To start the pandemic, you randomly mark a small number of citizens as sick there can be a
parameter for the number of initially infected citizens. You can start with 1 or 2 initial sick cases.
4. One iteration is one day. During the day, every citizen can meet a random number (say
between 0 and 20 inclusive) of randomly selected citizens. You dont really need to control all
citizens as we are interested in meetings of sick people only. We dont care how many healthy
people meet each other.
5. Every sick citizen can stay sick and infectious for 10 days, hence you should have some
counter for each sick citizen. After 10 days a sick citizen becomes healthy and stops spreading
the virus
6. Obviously, dead citizens cannot become sick, they dont meet anyone and, as a result, cannot
infect anyone.
7. During the day every sick citizen has a probability to die (mortality rate) from the disease with
probability 0.5% (quite low probability).
8. If a sick citizen does not die, then they can meet other people as per the rule 4 above, and if
they meet a healthy person, that person might become sick too and start infecting other people
starting from the next day (that is an infection day is day 0 of their sickness). The probability for
a citizen of becoming sick (infection rate) after a contact is 30% (this is quite high).
9. (New rule!) After surviving the infection and getting healthy, the person becomes immune.
This is a partial immunity. It does not make the person invincible but reduces the chance of
infection in future meetings with sick people. Take the immunity coefficient as 0.1. That is, a
probability of being infected for immune person is ten times lower than for the person without an
immunity. The infection rate for the immune person is the original infection rate multiplied by
the immunity coefficient, e.g. (0.3*0.1).
For the test, you can set immunity coefficient equal 1, which means no benefits of immunity and
the result should be the same as in Python example I presented.
10. You should run this simulation for a number of days (iterations) and store each da.
Sergio and Malena were married for 10 years before Malena unexpected.pdfsnewfashion
Sergio and Malena were married for 10 years before Malena unexpectedly passed away in 2021.
Sergio has a qualifying child dependent, Tomas (age 6), who lived with him all year. Sergio pays
all the cost of maintaining the home for himself and Tomas. Sergio has not remarried. In 2021,
Sergio filed his tax return as married filing jointly. Provided Sergio does not remarry by
December 31 of the current tax year, what is Sergio's correct and most favorable filing status for
2022?
Which of the following taxpayers may file as a Qualifying surviving spouse for 2022?
Ling (53) is unmarried and pays 75% of the cost of maintaining a home for her father, Tao (79),
who had no taxable income and did not live with Ling. Tao is Ling's qualifying relative
dependent, and she will claim him on her tax return in 2022. What is Ling's correct and most
favorable filing status for 2022?
Which of the following statements regarding the "tiebreaker" rules for claiming benefits,
including the Earned Income Credit (EIC), is TRUE?
Ladonna and Gabe are divorced and have one child. Ladonna is the custodial parent. For 2022,
Ladonna signed Form 8332, Release/Revocation of Release of Claim to Exemption for Child by
Custodial Parent, and gave the child's exemption to Gabe. Assuming all other requirements are
met, which benefits may Ladonna claim for this dependent?
Freida is not married. Her son, Diego, lived with her all year. To claim the filing status of head
of household, Freida must:
Which taxpayer may file as head of household? (If the scenario states the dependent is a
qualifying child or qualifying relative, it means they have passed all the dependency
requirements.)
Terry and Sal divorced in 2019. During 2022, their son Nick lived with his mother, Terry,
Terry's mother (Andrea), and Terry's best friend (Vanna) from January 1 to November 1. During
that time, Nick visited Sal every other weekend for a total of 40 nights.
On November 2, Nick went to live with Sal for the rest of the year. After that time, Nick visited
Terry, Andrea, and Vanna every other weekend for a total of 16 nights.
Terry's adjusted gross income (AGI) was $33,100, Andrea's AGI was $21,500, Vanna's AGI was
$32,600, and Sal's AGI was $29,900.
Who has the superior claim to Nick's dependency?.
Seg�n Bauer (2004), los sistemas de incorporaci�n var�an desde un en.pdfsnewfashion
Segn Bauer (2004), los sistemas de incorporacin varan desde un enfoque muy estructurado hasta
un enfoque ms de "hundirse o nadar". Las investigaciones muestran que la incorporacin formal
aumenta significativamente la satisfaccin y la retencin de los empleados; sin embargo, muchas
empresas carecen de procesos de incorporacin slidos que ayuden al nuevo empleado a
comprender su trabajo y la cultura organizacional y a conectarse con la organizacin. La
incorporacin tiene cuatro niveles distintos o componentes bsicos: cumplimiento, aclaracin,
cultura y conexin. El grado en que una organizacin aborda los cuatro se divide en tres niveles:
Pasivo Alto Potencial Proactivo Estrategias de incorporacin Bauer, T. (2004) Considere las
mejores y peores experiencias de incorporacin que haya tenido y comprelas aplicando los niveles
de estrategia de incorporacin y cmo abordaron las cuatro C. Alguna vez ha dejado un trabajo
debido a una mala incorporacin? Pngase en el lugar de un empleador que tiene tiempo y recursos
financieros limitados para la incorporacin, qu estrategias utilizara para incorporar eficazmente a
sus nuevos empleados?.
Select Your Tool Choose the tool that suits your preference�whether.pdfsnewfashion
Select Your Tool: Choose the tool that suits your preferencewhether it's a word processor,
PowerPoint, or the traditional pencil and ruler method.
Hierarchy of Pages: Begin by listing the main pages of your website. These are the primary
sections that users will navigate to. Each main page should be a distinct shape or box in your site
map.
Page Relationships: Connect the main pages using lines or arrows to indicate how users will
navigate from one page to another. Consider the logical sequence and connections between
pages.
Subpages and Content: If your main pages have subpages or additional content, represent them
as branches from the main pages. Connect these subpages to their respective main pages.
Navigation Flow: Ensure that the site map accurately reflects the navigation flow users will
follow when exploring your website. This includes clicking on links, buttons, or menus to access
different pages.
Annotations: You may find it helpful to include brief annotations or descriptions near each page
or connection to clarify the purpose or content of that specific element.
i did it im just not sure im on the right track.
Sarasota Company has decided to expand its operations. The bo Prepar.pdfsnewfashion
Sarasota Company has decided to expand its operations. The bo Prepare a revised balance sheet
given the available information. Assume that the accumulated depreciation balance for the
buildings is $167,500 and for the equipment, $112,500. The allowance for doubtful accounts has
a balance of $24,500. The pension obligation is considered a long-term liability. (List Current
Assets in order of liquidity. List Property, Plant, and Equipment in order of Buildings and
Equipment. Enter account name only and do not provide the descriptive information provided in
the question.)
Sarasota Company has decided to expand its operations. The bookkeeper recently completed the
following balance sheet in order to obtain additional funds for expansion..
reword this paragraph The �digital divide� is a term used to descr.pdfsnewfashion
reword this paragraph " The digital divide is a term used to describe the unequal distribution and
use of digital technology among people. In the 1990s with the introduction of computers and the
internet it was seen that only a small minority of persons had access to computers and/or the
internet to particularly those that were of the upper classes of society and developed countries.
During their introduction, these technologies were caused a social division amongst individuals
as these items were seen as a luxury that only the wealthy and those in urban areas could afford.
This social division has been seen with other technologies when they were first introduced such
as electricity, telephones and even television. However, just like the other technologies, the value
of these items was realised
overtime and their designs changed and the cost dropped to reduce exclusivity and
accommodate individuals regardless of their status in society. These digital divides do not
differ much from the social divisions that emerge when other technologies were
introduced, regarding who first had access to them, but the rate at which the gap is
reduced is significantly better when it comes to digital technology. The new form of the
digital divide will be how data literacy and having digital skills to compete in the new
digital age that is coming..
Scenario 3 Urgent Care CenterImplement and plan steps necessary f.pdfsnewfashion
Scenario 3: Urgent Care Center
Implement and plan steps necessary for opening a new health care facility on the west side of the
city.There are only one centralized hospital and one urgent care center, and they are all in the
center of town.Many residents on the west side of town have close to a 40-minute drive to either
of these facilities. Theexisting urgent care facility closes at 7:00 P.M., leaving the emergency
department at the hospital as theonly option for those seeking treatment later in the
evening.Location is one of the most important deciding factors when opening an urgent care
center. The west side ofthe city includes a Wal-Mart, Sams Club, CVS, and Walgreens. These
stores create high traffic volume andhouse an ideal strategic location for an urgent care center.
There are no medical centers of any kind on thisside of town, and there is a large community of
about 81,000 residents.
Objectives
To improve public health and provide basic clinical care for families and patients on the west
side of the city.The objectives of the new urgent care center are to:
1. Provide added primary care options - We aim to provide accessible and convenient primary
healthcare services for the residents the west side of the city. The opening of this new urgent care
center will reduce travel time for patients who need immediate medical attention to improve
patient outcomes.
2. Provide x-ray and lab options for patients - This new urgent care center involves making
diagnostic services more accessible to our patients. Implementing diagnostic healthcare services
to a wider range in our community will ensure that our patients receive collaborative,
comprehensive, and high quality care.
3. Add affordable options for care and referrals to local physicians and facilities - Affordable
options for care focuses on improving access to healthcare by offering cost-effective healthcare
services to our patients. We will implement programsadd networks that will connect patients to
healthcare in their local area that is convenient and affordable to them.
4. Extend operating hours - Residents of the west side of the city currently have a 40 minute
commute to the hospital, which is the only option for medical attention after 7:00pm. Our new
urgent care center will offer extended hours of operation to ensure accessible and convenient
care to patients later in the evening. Having access to a closer healthcare facility will improve
patients outcomes who need immediate medical care in the case of an emergency.
5. Accredit the new facility as an urgent care center - We will obtain the necessary legal and
official certifications and licenses for our healthcare facility to ensure compliance with legal,
safety, and regulatory requirements to successfully operate as an urgent care center. This will
also include assessing and improving facilities safety procedures and precautions and providing
annual trainings to staff.
Financial Review
Personnel - $300,000.00
Contractual Services $.
Requirement 2. Prepare a statement of stockholders equity forCent.pdfsnewfashion
Requirement 2. Prepare a statement of stockholders' equity for
Central Wireless, Inc.
for the month ended
October
31,
2025.
\begin{tabular}{|c|c|c|c|} \hline Date & Accounts and Explanation & Debit & Credit \\ \hline
Oct. 9 & CashCommonStock$4ParValuePaid-InCapitalinExcessofPar-
CommonIssuedcommonstockforcash. & 90,000 & 72,00018,000 \\ \hline Date & Accounts and
Explanation & Debit & Credit \\ \hline Oct. 10 & CashDividendsDividendsPayable-
PreferredDividendsPayable-CommonDeclaredcashdividend. & 17,000 & 2,24014,760 \\ \hline
\end{tabular}
Central Wireless, Inc. needed additional capital to expand, so the business incorporated. The
charter from the state of New Mexico authorizes Central Wireless, Inc. to issue 130,000 shares of
8%,$70 par value cumulative preferred stock and 210,000 shares of $4 par value common stock.
During the first month, Central Wireless, Inc. completed the following transactions: Assume
Central Wireless, Inc.'s net income for the month was $95,000.
Journal Entries
\begin{tabular}{|c|c|c|c|} \hline Date & Accounts and Explanation & Debit & Credit \\ \hline
\multirow[t]{4}{*}{ Oct. 25} & Dividends Payable_-Preferred & 2,240 &
\multirow{4}{*}{17,000} \\ \hline & Dividends Payable-Common & 14,760 & \\ \hline & Cash
& & \\ \hline & Paid cash dividend. & & \\ \hline \end{tabular}.
Task 5 Policy review 5 Why might the health and safety policy requi.pdfsnewfashion
Task 5: Policy review 5 Why might the health and safety policy require a review? (15) Note:
You should support your answer, where applicable, using relevant information from the scenario.
Secure National is a privately-owned security services organisation. They succeeded in a recent
takeover following the bankruptcy of another security organisation. Restructuring of the
organisation means that Secure National operates from a head office in a city centre. The new
owner is the managing director (MD) and a board of six other directors form the management
team (MT). The rest of the head offices workforce consists of various departments, comprising
of human resources, IT, finance, and general administration. The organisation has five regional
offices across the country. The MT is satisfied that regional office managers (ROMs)
successfully manage on-site security operations. The MT only gets involved with significant
problems. The regional offices operate 24 hours every day, with a reduced number of workers
between 20:00 06:00 for dealing with emergencies. Most of the regional workforces are made
up of security officers (SOs) working on sites where Secure National have been awarded
contracts to operate. Around the country, Secure National operates 818 sites and employs 2404
security officers to operate these sites. The sites generally have more than one SO on duty at the
same time, but there are a small number of sites (91) where only one SO is on duty at any one
time. The SOs complete a training course to obtain a required government license (RGL) and
also train as a first-aider. Only licenced SOs are allowed to be on duty at the sites. SOs are
required to attend one-to-one meetings twice a year with ROMs at their regional office. These
meetings are usually to discuss progress, receive feedback and resolve any local issues. The site
Secure National has been responsible for security at an onshore windfarm for 10 years. The
windfarm is in a remote location that has annual average temperatures between -5C (23F) and
13C (55.4F). When constructed, the site had five wind turbines across a fenced-in hillside, with a
gatehouse at the entrance where the SOs are based. A year ago, the fenced-in area was expanded
and five more wind turbines were added to the site. To help ensure that there are no unauthorised
visitors to the windfarm, the SOs periodically patrol the site to check the perimeters and the
locations around each wind turbine. A new design of electronic monitoring system was installed
to replace an outdated one at the same time that the additional wind turbines were installed. The
SOs scan ID cards at each wind turbine to confirm when they have checked that location. The
scanned data is kept in a digital log that the automated system periodically sends to the regional
office. The log can also be accessed on a computer at the gatehouse. If the regional office does
not receive data after six hours, the SOs are contacted by the office to determine wh.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
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.
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.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
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!
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Solve the coding errors for upvotemake test-statsg++ -g -std=c++.pdf
1. Solve the coding errors for upvote
make test-stats
g++ -g -std=c++14 -Wall -Werror=return-type -Werror=uninitialized -Wno-sign-compare -o test-
stats stats.o week-data.o test/catch/catch.o test/test-stats.o
Undefined symbols for architecture x86_64:
"stDev(WeekData*, int)", referenced from:
C_A_T_C_H_T_E_S_T_2() in test-stats.o
C_A_T_C_H_T_E_S_T_4() in test-stats.o
"getMean(WeekData*, int)", referenced from:
C_A_T_C_H_T_E_S_T_0() in test-stats.o
C_A_T_C_H_T_E_S_T_4() in test-stats.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [test-stats] Error 1
make test-state
g++ -g -std=c++14 -Wall -Werror=return-type -Werror=uninitialized -Wno-sign-compare -c -o
state.o state.cpp
state.cpp:65:12: error: no member named 'stDev' in 'State'; did you mean simply 'stDev'?
return State::stDev(weeks, numberOfDataPoints);
^~~~~~~~~~~~
stDev
./stats.hpp:5:19: note: 'stDev' declared here
static double stDev(WeekData* weeks, int count);
^
1 error generated.
make: *** [state.o] Error 1
make test-morbidity
g++ -g -std=c++14 -Wall -Werror=return-type -Werror=uninitialized -Wno-sign-compare -c -o
state.o state.cpp
state.cpp:65:12: error: no member named 'stDev' in 'State'; did you mean simply 'stDev'?
return State::stDev(weeks, numberOfDataPoints);
^~~~~~~~~~~~
stDev
./stats.hpp:5:19: note: 'stDev' declared here
static double stDev(WeekData* weeks, int count);
3. #include "../state.hpp"
#include "catch/catch.hpp"
TEST_CASE("Testing State class on calculation") {
State bama("Alabama");
CHECK("Alabama" == bama.getName());
bama.addWeek("2020-05-02,2000");
bama.addWeek("2020-05-09,2000");
bama.addWeek("2020-05-16,100");
bama.addWeek("2020-05-23,2000");
bama.addWeek("2020-05-30,2000");
bama.addWeek("2020-06-06,2000");
CHECK(Approx(1683.33).epsilon(0.01) == bama.getMeanDeaths());
CHECK(Approx(708.08).epsilon(0.01) == bama.getStDev());
CHECK(1 == bama.getOutlierCount());
auto outliers = bama.getOutlierInfos();
CHECK("2020-05-16 - total deaths: 100" == outliers.at(0));
}
TEST_CASE("Testing State class on rule of three") {
State bama("Alabama");
CHECK("Alabama" == bama.getName());
State bama1(bama);
CHECK("Alabama" == bama1.getName());
State bama2;
bama2 = bama;
4. CHECK("Alabama" == bama2.getName());
}
test-stats.cpp
#include "catch/catch.hpp"
#include "../stats.hpp"
#include "../week-data.hpp"
WeekData data[] = {
WeekData("1776-07-04,1"), // Just some static test data.
WeekData("1776-07-11,2"), // The dates are not important
WeekData("1776-07-18,3"), // since we are just trying to test the
WeekData("1776-07-25,5"), // statistical calculations
WeekData("1776-08-02,6")
};
TEST_CASE("Testing Mean")
{
// Comparing doubles, can use Approx() to allow some epsilon difference
CHECK(Approx(3.4) == getMean(data, 5));
}
TEST_CASE("Testing Stdev")
{
CHECK(Approx(1.85).epsilon(0.01) == stDev(data, 5));
}
TEST_CASE("Testing empty list")
{
// let's call the getMean of no numbers: 0
CHECK(Approx(0) == getMean({}, 0));
CHECK(Approx(0) == stDev({}, 0));
5. }
// Compile & run:
// make clean test
morbidity.cpp
#include "morbidity.hpp"
#include "state.hpp"
#include
#include
Morbidity::Morbidity() : numberOfStates(0), states(nullptr) {
}
Morbidity::~Morbidity() {
for (int i = 0; i < numberOfStates; i++) {
delete states[i];
}
delete[] states;
}
bool Morbidity::load(const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open()) {
return false;
}
6. std::string line;
std::string stateName;
while (std::getline(file, line)) {
std::istringstream iss(line);
std::string state, weekData;
std::getline(iss, state, ',');
std::getline(iss, weekData);
if (state != stateName) {
stateName = state;
State* newState = new State(stateName);
if (numberOfStates < 65) {
if (states == nullptr) {
states = new State*[65];
}
states[numberOfStates] = newState;
numberOfStates++;
}
}
try {
int deaths = std::stoi(weekData);
if (states != nullptr) {
states[numberOfStates - 1]->addWeek(weekData);
}
} catch (const std::invalid_argument& e) {
7. }
}
file.close();
return true;
}
double Morbidity::getMean(const std::string& stateName) const {
for (int i = 0; i < numberOfStates; i++) {
if (states[i]->getName() == stateName) {
return states[i]->getMeanDeaths();
}
}
return -1.0;
}
int Morbidity::getStateOutlierCount(const std::string& stateName) const {
for (int i = 0; i < numberOfStates; i++) {
if (states[i]->getName() == stateName) {
return states[i]->getOutlierCount();
}
}
return 0;
}
std::vector Morbidity::getStateOutliers(const std::string& stateName) const {
for (int i = 0; i < numberOfStates; i++) {
if (states[i]->getName() == stateName) {
return states[i]->getOutlierInfos();