Skip to content

Instantly share code, notes, and snippets.

// knight's tour problem using a one dimensional array
// https://support.sas.com/resources/papers/proceedings15/3060-2015.pdf
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
@Chamauta
Chamauta / arrayPractice_02.cpp
Created March 2, 2022 20:38
creating dynamic arrays
#include <iostream>
// ================================================== Prototypes ======================================================= //
void get(int* (&), int&); // function prototypes
void print(int*, int);
// ================================================== Source ========================================================== //
int main()
@Chamauta
Chamauta / arrayPractice_01.cpp
Last active March 2, 2022 19:57
Passing dynamic arrays c++
// elaborated from https://github.com/Headturna/Examples/blob/master/Examples/Example34.cpp
#include<iostream>
// note arrays always pass by reference, so any change within the function modifies the passed array
void test1(int* (arr), int length) // passing a pointer to a function
{
for (int i = 0; i < length; i++)
{
@Chamauta
Chamauta / exercise_06-14.cpp
Created December 22, 2021 17:30
Deitel_Chapter_06_Exercise_14
/*6.14 (Rounding Numbers) Function floor can be used to round a number to a specific decimal
place.The statement
y = floor(x * 10 + 0.5) / 10;
rounds x to the tenths position(the first position to the right of the decimal point).The statement
y = floor(x * 100 + 0.5) / 100;
rounds x to the hundredths position(the second position to the right of the decimal point).Write
@Chamauta
Chamauta / exercise_06-13.cpp
Last active December 22, 2021 16:10
Deitel_Chapter_06_Exercise_13
/*6.13 (Rounding Numbers) An application of function floor is to round a value to it's nearest
integer. The statement
y = floor(x + .5);
rounds the number x to the nearest integrand and assigns the result to y. Write a program that reads
several numbers and uses the preceding statement to round each of these numbers to the nearest
integer. For each number processed, print both the original number and the rounded number.*/
// =============================================== 06-13 =============================================== //
@Chamauta
Chamauta / exercise_06-12.cpp
Last active December 19, 2021 11:43
Deitel_Chapter_06_Exercise_12
/*6.12 (Parking Charges) A parking garage charges a $2.00 minimum fee to park for up to three
hours.The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three
hours. The maximum charge for any given 24 - hour period is $10.00. Assume that no car parks for
longer than 24 hours at a time. Write a program that calculates and prints the parking charges for each
of three customers who parked their cars in this garage yesterday. You should enter the hours parked
for each customer.Your program should print the results in a neat tabular formatand should calculate
and print the total of yesterday’s receipts.The program should use the function calculateCharges to
determine the charge for each customer.Your outputs should appear in the following format :
Car Hours Charge