Skip to content

Instantly share code, notes, and snippets.

View mahata's full-sized avatar
💭
On parenting...

Yasunori MAHATA mahata

💭
On parenting...
View GitHub Profile
@mahata
mahata / 7.6.cpp
Created September 20, 2011 00:17
C++ Primer 7.6
#include <iostream>
void Fill_array(double array[], int size);
void Show_array(const double array[], int size);
void Reverse_array(double array[], int size);
int main()
{
// using namespace std;
@mahata
mahata / 7.7.cpp
Created September 21, 2011 05:10
C++ Primer 7.7
#include <iostream>
const int Max = 5;
// function prototypes
double * fill_array(double ar[], int limit);
void show_array(const double ar[], double * n);
void revalue(double r, double ar[], double * n);
int main()
{
@mahata
mahata / 7.8.cpp
Created September 22, 2011 04:54
C++ Primer 7.8
#include <iostream>
using namespace std;
const int SLEN = 30;
struct student {
char fullname[SLEN];
char hobby[SLEN];
int ooplevel;
};
@mahata
mahata / 7.9.cpp
Created September 22, 2011 10:34
C++ Primer 7.9
double add(double x, double y);
double sub(double x, double y);
double calculate(double x, double y, double (*pf[2])(double, double));
#include <iostream>
int main()
{
using namespace std;
@mahata
mahata / 8.1.cpp
Created September 25, 2011 18:58
C++ Primer 8.1
#include <iostream>
const int max_str_len = 255;
void silly_function(char * print_string, int flag = 0);
int main()
{
using namespace std;
char sample_string[max_str_len] = "Hello, world!";
@mahata
mahata / 8.2.cpp
Created September 26, 2011 03:45
C++ Primer 8.2
#include <iostream>
#include <cstring>
const int MAX_STR_LEN = 255;
struct CandyBar
{
char brand[MAX_STR_LEN];
double weight;
int calorie;
@mahata
mahata / 8.4.cpp
Created September 28, 2011 20:12
C++ Primer 8.4
#include <iostream>
using namespace std;
#include <cstring> // for strlen(), strcpy()
struct stringy {
char * str;
int ct;
};
void set(stringy & stringy_ref, char * cstring);
@mahata
mahata / 8.3.cpp
Created September 28, 2011 20:15
C++ Primer 8.3
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
void capitalize_all(string & text);
int main()
{
@mahata
mahata / 8.5.cpp
Created September 28, 2011 23:14
C++ Primer 8.5
#include <iostream>
const int ARRAY_SIZE = 5;
template <typename T>
T max5(T number[]);
int main()
{
using namespace std;
@mahata
mahata / 8.6.cpp
Created September 29, 2011 04:24
C++ Primer 8.6
#include <iostream>
#include <cstring>
template <typename T>
T maxn(T number[], int num_of_elements);
template <> const char * maxn(const char * cstring_array[], int num_of_cstrings);
int main()
{