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

c++ 面试100个题目中的编程题目

 88、下列程序的运行结果是?

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>    const char* str = "vermeer";
using namespace std;
int main(){ const char* pstr = str;cout << "The address of pstr is: " << pstr << endl;return 0;}



89、下列程序输出结果是?

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>    
using namespace std;
inline void max_out(int val1, int val2)
{cout << (val1 > val2) ? val1 : val2;
}int main()
{int ix = 10, jx = 20;cout << "The larger of " << ix;cout << ", " << jx << " is ";max_out(ix, jx);cout << endl;
}




90、int max( int *ia, int sz ); 

int max( int *, int = 10 ); 
算函数重载?还是重复声明?
如果在两个函数的参数表中只有缺省实参不同则第二个声明被视为第一个的重复声明 。

91、请编写一个 C++函数,该函数给出一个字节中被置 1 的位的个数。

#include <iostream>
using namespace std;unsigned int TestAsOne0(char log)
{int i;unsigned int num = 0, val;for (i = 0; i < 8; i++){val = log >> i;//移位val &= 0x01;   //与1相与if (val)num++;}return num;
}int main() {char q = 'a';cout << "ascis q=" << q-0 << endl;int c = TestAsOne0(q);cout << "c=" << c << endl;return 0;
}

输入为a
在这里插入图片描述

输出

ascis q=97
c=3

92、编写一个函数,函数接收一个字符串,是由十六进制数组成的一组字符串,函数的功能是把接到的这组字符串转换成十进制数字.并将十进制数字返回。

#include <iostream>
#include <string>
#include <sstream>
using namespace std;int main()
{string str1("1024");stringstream ss1;int d1;ss1 << str1;ss1 >> d1;cout << d1 << endl;stringstream ss2;int d2;string str2("1aF"); //1aF十进制431ss2 << hex << str2; //选用十六进制输出ss2 >> d2;cout << d2 << endl;system("pause");return 0;
}



93、输入一个字符串,将其逆序后输出 
 

 <stdio.h>
#include<string.h>void stringNx(char a[])
{int i = strlen(a) - 1;
http://www.lryc.cn/news/318504.html

相关文章:

  • C++初阶:类与对象(尾篇)
  • Spring状态机简单实现
  • WebServer -- 面试题(下)
  • 企业微信如何接入第三方应用?
  • JAVA后端编码的主键字段存储为什么倾向于使用雪花算法
  • Rust 深度学习库 Burn
  • C语言-存储期2.0
  • 计算机网络面经八股-HTTP请求报文和响应报文的格式?
  • Ubuntu 18.04安装最新版Visual Studio Code(VS Code)报依赖库版本过低错误
  • Android NDK入门:在应用中加入C和C++的力量
  • 2024年华为OD机试真题-田忌赛马-Java-OD统一考试(C卷)
  • C++ 网络编程学习五
  • 案例分析篇05:数据库设计相关28个考点(9~16)(2024年软考高级系统架构设计师冲刺知识点总结系列文章)
  • pip 和conda 更换镜像源介绍
  • Git概述及安装步骤
  • 北京保险服务中心携手镜舟科技,助推新能源车险市场规范化
  • 给女朋友的浪漫微信消息推送超详细版
  • Android开发 Activity启动模式、ViewModel与LiveData,及Kotlin Coroutines
  • MQL语言实现抽象工厂模式
  • UE4开个头-简易小汽车
  • Java基础入门day04
  • 中值定理j
  • 第2篇【Docker项目实战】使用Docker部署Raneto知识库平台(转载)
  • 【Javascript】 Promise 对象(二)
  • 细说C++反向迭代器:原理与用法
  • SpringBoot(依赖管理和自动配置)
  • cad怎么转换成黑白的pdf图纸?分享3个常用的软件!
  • maven本地仓库依赖上传到远程仓库
  • ISIS多区域实验简述
  • go语言基础笔记