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

上海网站建设有限公司麦德龙网上商城

上海网站建设有限公司,麦德龙网上商城,专业订制网站制作,手游排行榜前十名网络游戏C语言作为一门广泛使用的编程语言#xff0c;已经成为了许多IT领域从业者的必备技能之一。为了帮助大家更好地掌握C语言#xff0c;本文将为大家提供一些专门的C真题。 1. 指针 题目一#xff1a;请编写一个函数#xff0c;函数名为swap#xff0c;交换两个整数型变量的…        C语言作为一门广泛使用的编程语言已经成为了许多IT领域从业者的必备技能之一。为了帮助大家更好地掌握C语言本文将为大家提供一些专门的C真题。 1. 指针 题目一请编写一个函数函数名为swap交换两个整数型变量的值。 void swap(int *a, int *b) {int temp *a;*a *b;*b temp; } 题目二请编写一个函数实现对一个整型数组进行冒泡排序。 void bubble_sort(int arr[], int len) {for (int i 0; i len - 1; i) {for (int j 0; j len - i - 1; j) {if (arr[j] arr[j 1]) {swap(arr[j], arr[j 1]);}}} } 题目三请编写一个函数实现将一个字符数组中的每个字符倒序输出。 void reverse_string(char *str) {int len strlen(str);for (int i len - 1; i 0; i--) {cout str[i];} } 2. 继承与多态 题目一请编写一个基类Shape和三个派生类Circle、Rectangle和Triangle实现求各自面积的功能。 class Shape { public:virtual double get_area() {return 0;} };class Circle : public Shape { private:double r;public:Circle(double r) {this-r r;}double get_area() {return 3.14 * r * r;} };class Rectangle : public Shape { private:double l, w;public:Rectangle(double l, double w) {this-l l;this-w w;}double get_area() {return l * w;} };class Triangle : public Shape { private:double a, b, c;public:Triangle(double a, double b, double c) {this-a a;this-b b;this-c c;}double get_area() {double p (a b c) / 2;return sqrt(p * (p - a) * (p - b) * (p - c));} }; 题目二请编写一个基类Animal和三个派生类Cat、Dog和Bird实现各自发出声音的功能。 class Animal { public:virtual void make_sound() {cout Animal makes sound! endl;} };class Cat : public Animal { public:void make_sound() {cout Meow~ endl;} };class Dog : public Animal { public:void make_sound() {cout Woof! endl;} };class Bird : public Animal { public:void make_sound() {cout Chirp~ endl;} }; 3. STL库 题目一请使用STL库中的vector定义一个整型数组并利用vector进行遍历、排序、查找等操作。 vectorint vec {8, 3, 6, 2, 7, 4, 1, 5};// 遍历 for (auto item : vec) {cout item ; } cout endl;// 排序 sort(vec.begin(), vec.end()); for (auto item : vec) {cout item ; } cout endl;// 查找 auto it find(vec.begin(), vec.end(), 7); if (it ! vec.end()) {cout Found: *it endl; } else {cout Not found! endl; } 题目二请使用STL库中的map定义一个字典实现添加、查找、删除单词的功能。 mapstring, string dict;// 添加单词 dict.insert(pairstring, string(apple, 苹果)); dict.insert(make_pair(banana, 香蕉)); dict[cherry] 樱桃;// 查找单词 auto it dict.find(apple); if (it ! dict.end()) {cout it-second endl; } else {cout Not found! endl; }// 删除单词 dict.erase(banana); 4. 文件操作 题目一请编写一个程序将一个文本文件中的每一行反转。 ifstream fin(input.txt); ofstream fout(output.txt);string line; while (getline(fin, line)) {reverse(line.begin(), line.end());fout line endl; }fin.close(); fout.close(); 题目二请编写一个程序实现将一个二进制文件中的数据进行加密和解密。 ifstream fin(input.bin, ios::binary); ofstream fout(output.bin, ios::binary);char key 123; // 密钥可以自己定义char ch; while (fin.get(ch)) {ch ^ key; // 异或运算实现加密和解密fout.put(ch); }fin.close(); fout.close();
http://www.sadfv.cn/news/234066/

相关文章:

  • 网站建设怎么做网站好看的个人博客主页
  • 做网站的知识室内设计效果图在哪里找
  • 回龙观做网站免费的app软件下载安装
  • 内部购物券网站怎么做wordpress 文章打不开
  • gl账号注册网站红动在线设计平台
  • cnzz站长统计怎么添加到博客网站seo最好的网站
  • 在线网站做气泡图价格信息网
  • wordpress漂亮手机网站上海中风险地区地图
  • 做教育网站用什么颜色黄岛英文网站建设
  • 工会网站建设请示抖音代运营案例
  • 重庆龙华网站建设公司怎么在建筑网站做翻译兼职
  • 网站设计计费网站建设项目汇报
  • 没有网站怎么做cpa赚钱做的网站提示不安全问题
  • 厦门网站模板网站一直显示建设中
  • 网站主页设计要点wordpress自动发货插件
  • 南宁营销型网站建设公司哪家好网站流量指的是什么意思
  • 网站设计步骤包括哪些androidapp开发教程
  • 做混剪素材网站seo推广培训
  • 查网站域名备案网络营销的基本概念
  • 设计网站大全铲鼠湖南岚鸿相信分销平台哪个好
  • 网站改版方案策划书wordpress后台中文
  • 网站策划编辑网站迁移教程
  • 深圳网站建设认准乐云践新学院网页设计
  • 常用的网站开发语言免费国外在线代理服务器
  • 深圳做网站哪家便宜wordpress用什么域名好
  • 烟台哪家公司可以做网站linux下网站开发
  • 网站建设图片编辑dlog4j wordpress
  • 网站推广营销方法江苏省建设厅网站怎么登不上
  • 长沙建网站的公司一对一定制方案台州关键词优化哪家好
  • 网站分页符怎么做百度一下浏览器下载安装