我遇到了一个面试问题,内容如下:
"编写一个简单的C/C++宏来查找最多两个数字而不使用std库或三元运算符".
我需要你帮助解决这个问题.我知道这是微不足道的,但我找不到它.所以,在这里发布.
#include<iostream>
#define max(x,y) /*LOGIC HERE*/
using namespace std;
void main()
{
int a = 98453;
int b = 66394;
cout<<max(a,b);
}
Run Code Online (Sandbox Code Playgroud) 我对SIP有一个小小的疑问。我尝试使用谷歌搜索和引用许多书籍,但仍然找不到在SIP请求中添加from-tag的可靠原因。
SIP请求示例(来自rfc-3261的快照)
INVITE sip:bob@biloxi.com SIP/2.0
Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds
Max-Forwards: 70
To: Bob <sip:bob@biloxi.com>
From: Alice <sip:alice@atlanta.com>;tag=1928301774
Call-ID: a84b4c76e66710@pc33.atlanta.com
CSeq: 314159 INVITE
Contact: <sip:alice@pc33.atlanta.com>
Content-Type: application//sdp
Content-Length: 142
Run Code Online (Sandbox Code Playgroud)
根据rfc-3261:
对话框可以使用from-tag,to-tag和call-id进行标识。
我知道添加to-tag和call-id的确切原因。我不知道的是
我正在阅读Milan Stevanovic撰写的名为"高级C和C++编译"的书
以下是本书的快照,其次是我面临的问题.
概念图:演示项目
用于构建这个简单项目的开发环境将基于在Linux上运行的gcc编译器.清单2-1到2-3包含演示项目中使用的代码.
清单2-1. function.h
#pragma once
#define FIRST_OPTION
#ifdef FIRST_OPTION
#define MULTIPLIER (3.0)
#else
#define MULTIPLIER (2.0)
#endif
float add_and_multiply(float x, float y);
Run Code Online (Sandbox Code Playgroud)
清单2-2. function.c
int nCompletionStatus = 0;
float add(float x, float y)
{
float z = x + y;
return z;
}
float add_and_multiply(float x, float y)
{
float z = add(x,y);
z *= MULTIPLIER;
return z;
}
Run Code Online (Sandbox Code Playgroud)
清单2-3. main.c
#include "function.h"
extern int nCompletionStatus = 0;
int main(int argc, char* argv[])
{
float x …Run Code Online (Sandbox Code Playgroud)