/*******************************************************************************************************************
Author : Cui mingyang
Blog : cx_12586
Time : 2017/11/1
From : C++ Primer Plus第五版第8章编程练习 第1题
*******************************************************************************************************************/
#include<iostream>
const int ArSize = 80;
using namespace std;
void Printf(const char *ch,int n=1);
static int count=0;
int main()
{
cout << "Enter a string: \n";
char ch[80];
cin.get(ch,ArSize);
cout << "#1 " <<endl;
Printf(ch,20);
cout << "#2 " <<endl;
Printf(ch,40);
cout << "#3 " <<endl;
Printf(ch,10); ;
cout << "#4 " <<endl;
Printf(ch);
system("pause");
return 0;
}
void Printf(const char *ch,int n)
{
++count;
if (n)
{
for (int i=0;i<count;i++)
cout << ch <<endl;
}
else
cout << ch <<endl;
}
/*******************************************************************************************************************
Author : Cui mingyang
Blog : cx_12586
Time : 2017/11/1
From : C++ Primer Plus第五版第8章编程练习 第2题
*******************************************************************************************************************/
#include<iostream>
const int ArSize = 80;
using namespace std;
struct CandyBar
{
char brand[ArSize];
double weight;
int heat;
};
void fill_it(CandyBar &a,const char *ch="Millennium",double weight=2.85,int heat=350);
void show (const CandyBar &a);
int main()
{
CandyBar candy1;
cout << "Enter the brand of the candy: \n";
char name[ArSize];
cin.get(name,ArSize);