当前位置: 首页 > news >正文

织梦英文版网站怎么做世界三大咨询公司

织梦英文版网站怎么做,世界三大咨询公司,代理公司注册要提供什么资料,门户网站开发架构文章目录 第一章 C编程基础1.41.51.61.71.8 第二章 面向过程的编程风格2.12.22.32.42.52.6 第一章 C编程基础 1.4 /*********************************************************************说明:试着扩充这个程序的内容#xff1a;#xff08;1#xff09;要求用户同时输… 文章目录 第一章 C编程基础1.41.51.61.71.8 第二章 面向过程的编程风格2.12.22.32.42.52.6 第一章 C编程基础 1.4 /*********************************************************************说明:试着扩充这个程序的内容1要求用户同时输入名字first name和姓氏last name 2修改输出结果同时打印出姓氏和名字。 *********************************************************************/ #include iostream #include string using namespace std;int main() {string user_name;cout 输入名字\n;cin user_name;cout \n你好 user_name;return 0; } 1.5 /*********************************************************************说明:编写一个程序能够询问用户的姓名并读取用户所输入的内容。请确保用户输入的名称长度大 于两个字符。如果用户的确输入了有效名称就响应一些信息。请以两种方式实现第一种使用 C-style字符串第二种使用string对象。 *********************************************************************/ #include iostream #include string #include cstring using namespace std;//使用string对象 int main() {string usr_name;cout Please enter your name: endl;cin usr_name;switch (usr_name.size()) {case 0:cout Fail,No Name.;break;case 1:cout Fail,Onlu A 1-character name.;break;default :cout Hello, usr_name endl;}return 0; } 1.6 /*********************************************************************说明:编写一个程序从标准输入设备读取一串整数并将读入的整数依次放到array及 vector然后遍历这两种容器求取数值总和。将总和及平均值输出至标准输出设备 *********************************************************************/ #include iostream #include vector using namespace std;// 使用array实现 //int main() { // const int array_size 128; // int ia[array_size]; // // int ival, icnt 0; // ival用于暂存输入icnt表示输入数据量 // int sum 0; // cout Please Enter Some Numbers: endl; // // while (cin ival icnt array_size) { // ia[icnt] ival; // } // // for (int i 0; i icnt; i) { // sum ia[i]; // } // int average sum / icnt; // cout Sum of icnt // elements: sum // . Average: average endl; // return 0; //}//使用vector实现 int main() {const int array_size 128;vectorintia; //无需在初始化的时候就确实大小int ival 0; // ival用于暂存输入int sum 0;cout Please Enter Some Numbers: endl;while (cin ival ia.size() array_size) {ia.push_back(ival);}for (int i 0; i ia.size(); i) {sum ia[i];}int average sum / ia.size();cout Sum of ia.size() elements: sum . Average: average endl;return 0; } 1.7 /*********************************************************************说明:使用你最趁手的编辑工具输入两行或更多文字并存盘。然后编写一个程序打开该文本文 件将其中每个字都读取到一个vectorstring对象中。遍历该vector将内容显示到cout。 然后利用泛型算法sort()对所有文字排序 #include algorithm sort( container.beginer(), container.end() ); 再将排序后的结果输出到另一个文件。*********************************************************************/ #include iostream #include fstream #include vector #include algorithm #include string using namespace std;int main() {vectorstringistr;ifstream infile(ex1.7Read.txt);if (!infile) {cerr Fail infile!\n;} else {string word;while (infile word) {istr.push_back(word);}}// 排序sort(istr.begin(), istr.end());ofstream outfile(ex1.7Write.txt, ios_base::app);if (!outfile)cerr Fail outfile!\n;elsefor (int i 0; i istr.size(); i) {outfile istr[i] ;}outfile endl;return 0; } 1.8 /*********************************************************************说明:switch语句让我们得以根据用户答错的次数提供不同的安慰语句。请以array储存四种 不同的字符串信息并以用户答错次数作为array的索引值以此方式来显示安慰语句。 *********************************************************************/ #include iostream using namespace std;const char *msg_to_usr( int num_tries ) {const int rsp_cnt 5;static const char *usr_msgs[ rsp_cnt ] {Go on, make a guess. ,Oops! Nice guess but not quite it.,Hmm, Sorry. Wrong a second time.,Ah, this is harder than it looks, no?,It must be getting pretty frustrating by now!};if ( num_tries 0 ) {num_tries 0;} else if ( num_tries rsp_cnt ) {num_tries rsp_cnt - 1;}return usr_msgs[ num_tries ]; }int main() {cout msg_to_usr(3) endl;return 0; }第二章 面向过程的编程风格 2.1 /*********************************************************************说明: 先前的main()只让用户输入一个位置值然后便结束程序。如果用户想取得两个甚至更多元素值 他必须执行这个程序两次或多次。请改写main()使它允许用户不断输入位置值直到用户希望 停止为止。 *********************************************************************/ #include iostream using namespace std;bool fibon_elem(int, int );int main() {int pos, elem;char ch;bool more true;while (more) {cout 请输入一个位置 ;cin pos;if (fibon_elem(pos, elem)) {cout 此位置 pos 的值是 elem endl;} else {cout error;}cout 是否还要继续(Y/N)? endl;cin ch;if (ch ! y ch ! Y) {more false;}}return 0; }bool fibon_elem(int pos, int elem) {// 检查位置值是否合理if (pos 0 || pos 1024) {elem 0;return false;}// 位置值为1和2时elem的值为1int val 1;int n_1 1, n_2 1;switch (pos) {default:case 2:cout 1 ;case 1:cout 1 ;}for (int i 3; i pos; i) {val n_2 n_1;n_2 n_1;n_1 val;cout val (!(i % 10) ? \n\t : );}elem val;return true; }2.2 /*********************************************************************说明:Pentagonal数列的求值公式是 Pnni*(3r-1) /2借此产生15,12,22,35等元素值。试定义一个函数利用上述公式将产生的元素置人用户传入的 vector 之中元素数目由用户指定。请检查元素数目的有效性译注:太大则可能引发overflow问题)接下来撰写第二个函数能够将所接获的 vector 的所有元素一-一印出。此函数的第二参数接受一个字符串表示储存于vector 内的数列的类型。最后再写一个main( )测试上述两个函数。 *********************************************************************/ #include iostream #include vector #include fstreamusing namespace std;bool calc_elems(vectorint vec, int pos); void display_elems(vectorint vec, ostream os cout);int main() {vectorint pent;// 检查上面声明的两个函数if ( calc_elems( pent, 0 ))display_elems( pent );if ( calc_elems( pent, 8 ))display_elems( pent );ofstream ofil(ex2.2.txt);if ( calc_elems( pent, 14 ))display_elems( pent, ofil);if ( calc_elems( pent, 138 ))display_elems( pent );return 0; }bool calc_elems(vectorint vec, int pos) {if (pos 0 || pos 64) {cerr Sorry. Invaild position: pos endl;return false;}for (int ix vec.size() 1; ix pos; ix) {vec.push_back((ix * (3 * ix - 1)) / 2);};return true; };void display_elems(vectorint vec, ostream os) {os \nPentagonal Numeric Series\n\t;for (int ix 0; ix vec.size(); ix)os vec[ix] ;os endl; };2.3 /*********************************************************************说明:将练习2.2的Pentagonal数列求值函数拆分为两个函数其中之一为inline用来检验元素个数 是否合理。如果的确合理而且尚未被计算便执行第二个函数执行实际的求值工作。 *********************************************************************/ #include iostream #include vector #include fstreamusing namespace std;inline bool calc_elems(vectorint vec, int pos); extern void really_calc_elems(vectorint vec, int pos); void display_elems(vectorint vec, ostream os cout);int main() {vectorint pent;// 检查上面声明的两个函数if ( calc_elems( pent, 0 ))display_elems( pent );if ( calc_elems( pent, 8 ))display_elems( pent );ofstream ofil(ex2.3.txt);if ( calc_elems( pent, 14 ))display_elems( pent, ofil);if ( calc_elems( pent, 138 ))display_elems( pent );return 0; }bool calc_elems(vectorint vec, int pos) {if (pos 0 || pos 64) {cerr Sorry. Invaild position: pos endl;return false;}if ( vec.size() pos) {really_calc_elems( vec, pos);}return true; };void really_calc_elems(vectorint vec, int pos) {for (int ix vec.size() 1; ix pos; ix) {vec.push_back((ix * (3 * ix - 1)) / 2);}; }void display_elems(vectorint vec, ostream os) {os \nPentagonal Numeric Series\n\t;for (int ix 0; ix vec.size(); ix)os vec[ix] ;os endl; };2.4 /*********************************************************************说明:写一个函数以局部静态local static)的vector存储 Pentagonal数列元素。此函数返回一个const 指针指向该vector。如果 vector 的容量小于指定的元素数目就扩充 vector的容量。接下来再实现第二个函数接受一个位置值并返回该位置上的元素。最后撰写main (测试这些函数。*********************************************************************/ #include iostream #include vector #include fstream using namespace std;inline bool check_validity(int pos); const vectorint *initelems(int pos); void display_elems(vectorint vec, ostream os cout); bool get_elems(int pos, int elem);int main() {int elem;// 检查上面声明的两个函数if ( get_elems( 0, elem ))cout element 1 is elem \n;for (int i 1; i 10; i ) {if ( get_elems( i, elem ))cout element i \tis elem \n;}return 0; }bool check_validity(int pos) {return (pos 0 || pos 64) ? false : true; }const vectorint *initelems(int pos) {static vectorint elems;if (check_validity(pos) || pos elems.size()) {for (int ix elems.size() 1; ix pos; ix) {elems.push_back((ix * (3 * ix - 1)) / 2);};}return elems; }bool get_elems(int pos, int elem) {if ( !check_validity( pos )) {cout Sorry. Invalid position: pos endl;elem 0;return false;};const vectorint *elems initelems(pos);elem (*elems)[pos - 1];return true; }void display_elems(vectorint vec, ostream os) {os \nPentagonal Numeric Series\n\t;for (int ix 0; ix vec.size(); ix)os vec[ix] ;os endl; };2.5 /*********************************************************************说明:实现一个重载的max (〉函数让它接受以下参数:(a)两个整数;(b)两个浮点数;(c)两个字符串:(d)一个整数vector;(e)一个浮点数vector:(f)一个字符串 vector;(g)一个整数数组以及一个表示数组大小的整数值:(h)一个浮点数数组以及一个表示数组大小的整数值:(i)-个字符串数组以及一个表示数组大小的整数值最后撰写main()测试这些函数。 *********************************************************************/ #include iostream #include string #include algorithm #include vector using namespace std;inline int max (int a, int b); inline float max (float a, float b); inline string max (const string a, const string b); inline int max (const vectorint vec); inline float max ( const vectorfloat vec ); inline string max ( const vectorstring vec ); inline string max ( const string a, const string b ); inline int max ( const int *parray, int size ); inline float max( const float *parray, int size ); inline string max ( const string *parray, int size );int main() {string sarray[] { we, were, her, pride, of, ten };vectorstring svec( sarray, sarray 6 );int iarray[] { 12, 70, 2, 169, 1, 5, 29 };vectorint ivec( iarray, iarray 7 );float farray[] { 2.5, 24.8, 18.7, 4.1, 23.9 };vectorfloat fvec( farray, farray 5 );int imax max( max( ivec ), max( iarray, 7 ));float fmax max( max( fvec ), max( farray, 5 ));string smax max( max( svec ), max( sarray, 6 ));cout imax should be 169 -- found: imax \n fmax should be 24.8 -- found: fmax \n smax should be were -- found: smax \n;return 0; }int max (int a, int b) {return (a b) ? a : b; }float max (float a, float b) {return (a b) ? a : b; }string max ( const string a, const string b ) {return a b ? a : b; }int max ( const vectorint vec ) {return *max_element( vec.begin(), vec.end() ); }float max ( const vectorfloat vec ) {return *max_element( vec.begin(), vec.end() ); }string max ( const vectorstring vec ) {return *max_element( vec.begin(), vec.end() ); }int max ( const int *parray, int size ) {return *max_element( parray, parray size ); }float max( const float *parray, int size ) {return *max_element( parray, parray size ); }string max ( const string *parray, int size ) {return *max_element( parray, parray size ); }2.6 /*********************************************************************说明:以template 重新完成练习2.5并对main(〉函数做适度的修改. *********************************************************************/ #include iostream #include string #include algorithm #include vector using namespace std;template typename Typeinline Type mymax(Type t1, Type t2) {return (t1 t2) ? t1 : t2; }template typename elemTypeinline elemType mymax(const vectorelemType vec) {return *max_element( vec.begin(), vec.end() ); }template typename arrayTypeinline arrayType mymax(const arrayType *parray, int size) {return *max_element( parray, parray size ); }int main() {string sarray[] { we, were, her, pride, of, ten };vectorstring svec( sarray, sarray 6 );int iarray[] { 12, 70, 2, 169, 1, 5, 29 };vectorint ivec( iarray, iarray 7 );float farray[] { 2.5, 24.8, 18.7, 4.1, 23.9 };vectorfloat fvec( farray, farray 5 );int imax mymax( mymax( ivec ), mymax( iarray, 7 ));float fmax mymax( mymax( fvec ), mymax( farray, 5 ));string smax mymax( mymax( svec ), mymax( sarray, 6 ));cout imax should be 169 -- found: imax \n fmax should be 24.8 -- found: fmax \n smax should be were -- found: smax \n;return 0; }
http://www.yutouwan.com/news/486701/

相关文章:

  • 网站栏目架构网站安全建设方案例文
  • se 网站优化洛阳青峰网络
  • 换友情链接的网站深圳人才网官方网站
  • 学做西点的网站建立企业网站的形式有哪几种
  • 学校网站建设项目可行性分析网站空间管理面板
  • 专业的企业网站定制公司网站建设承诺
  • 做cpa比较做网站吗wordpress建站教程简书
  • 重庆建设银行官方网站首页seo网页推广
  • 商业网站建立大千设计装饰有限公司
  • 视频网站哪个做的好处网站站开发 流量
  • 最全的网页模板网站wordpress搭的
  • 学院网站信息化建设总结梵客家装全包套餐
  • 网站可信图标零食网站推广策划书
  • 那个网站可以找人做设计外包的企业网站
  • 公司网站数据分析公司北航网站建设
  • 做简单的网站首页天津效果图制作公司
  • 做视频网站的公司有哪些建筑网站大图
  • 铜梁网站建设网站建设有那些
  • 专业简历制作网站推荐水网站模板
  • 网站优化说明微站官网
  • 如何能让网站尽快备案通过包头市做网站公司
  • 怎么做一个网站网站建设内部下单流程
  • 医院病房建设网站达内网站开发培训
  • 怎么做网站卖东西公司网站建设费用如何做账
  • 漳州市城乡住房建设局网站东莞网络推广培训
  • 网页免费浏览网站seo技术什么意思
  • 网站模板预览与编辑器页面设计图标
  • 如何提高网站的排名有没有哪个网站怎么做动漫新闻的
  • 太原制作网站企业网站开发平台的公司
  • 旅游网站建设需求说明书网站开发案例教堂html