C++primer plus 第九章习题
来源:互联网 发布:ipad版怎么看淘宝直播 编辑:程序博客网 时间:2024/05/16 06:25
#ifndef GOLF_H_#define GOLF_H_const int len = 40;struct golf{<span style="white-space:pre"></span>char fullname[len];int handicap;};void setgolf(golf &g, const char* name, int hc);int setgolf(golf &g);void handicap(golf &g, int hc);void showgolf(const golf &g);#endif
#include<iostream>#include"golf.h"//第九章int main(){using namespace std;golf team[3];int i;for (i = 0; i < 3; i++){if (setgolf(team[i]) == 0)break;}for (int j = 0; j < i; j++){showgolf(team[j]);}golf ann;setgolf(ann, "ann bridfree", 5);showgolf(ann);handicap(ann, 3);showgolf(ann);system("pause");return 0;}
#include<iostream>#include<stdlib.h>#include<string>using std::string;using std::cin;using std::cout;using std::endl;void strcount(string str);int main(){string input;cout << "Enter line:";getline(cin, input);while (input != ""){strcount(input);cout << "Enter next line:";getline(cin, input);}cout << "Bye!"<<endl;}void strcount(string str){static int total = 0;int count = 0;cout << "\"" << str << "\"contains ";count=str.size();total += count;cout << count << " characters, ";cout << total << " characters total\n";}
#include<iostream>#include<stdlib.h>#include<cstring>struct chaff{char dross[20];int slag;};const int BUF = 60;char buf[BUF];int main(){using namespace std;chaff *pc = new(buf)chaff[2];strcpy_s(pc[0].dross, "fpoo");pc[0].slag = 1;strcpy_s(pc[1].dross, "mmpoo");pc[1].slag = 2;for (int i = 0; i < 2; i++){cout << pc[i].dross << ":" << pc[i].slag << endl;}system("pause");return 0;}
</pre><pre name="code" class="cpp">namespace SALES{const int QUARTERS = 4;struct Sales{double sales[QUARTERS];double average;double max;double min;};void setSales(Sales &s, const double ar[], int n);void setSales(Sales &s);void showSales(const Sales &s);}
#include<iostream>#include<stdlib.h>#include<cstring>#include"golf.h"int main(){using namespace SALES;Sales s1;double salesList[] = { 11.2, 11.3, 11.4, 11.5, 11.6 };setSales(s1, salesList, sizeof(salesList) / sizeof(double));showSales(s1);Sales s2;setSales(s2);showSales(s2);system("pause");return 0;}
0 0
- C++primer plus 第九章习题
- c++ primer plus第九章习题答案
- C Primer plus 第九章
- C++Primer习题第九章
- C Primer Plus 第九章课后习题……2015.5.1
- c primer plus 第九章 答案
- 《C Primer Plus》第九章编程题
- c primer plus第九章答案
- c++primer plus 第九章-名称空间
- C primer plus 第九章 练习1:
- C primer plus 第九章 练习2:
- C primer plus 第九章 练习3:
- C primer plus 第九章 练习4:
- C primer plus 第九章 练习5:
- C primer plus 第九章 练习6:
- C primer plus 第九章 练习7:
- C primer plus 第九章 练习8:
- C primer plus 第九章 练习9:
- Beanutils基本用法
- Windows 08 R2_NLB负载均衡(图文详解)
- 三十三、Java图形化界面设计——布局管理器之null布局(空布局)
- Android开发小知识
- 安卓设计的一些东西
- C++primer plus 第九章习题
- mongo的学习
- DB2分组函数ROLLUP和CUBE的使用
- ART、JIT、AOT、Dalvik之间的关系
- 项目完成了,如何做项目的总结会议?
- 静态链表(C++实现)
- 记录下mybatis中#{}和${}传参的区别
- Codeforces Round #101 (Div. 2) B. Hopscotch
- js 数据类型与转换