我想要做的是说单元格D3(在当前工作表上)的内容是否存在于A第一个工作表的列中(在我的案例中为名单列表).(而且它们总是在某处存在).返回Column中相应行的内容C.
换句话说,如果在Row中找到匹配的单元格12- 从中返回数据C12.
我使用了以下语法,但似乎无法使最后一部分正常工作.
=IF(ISERROR(MATCH(D3,List!A:A, 0)), "No Match", VLOOKUP(D3,List!A:A,1,TRUE))
Run Code Online (Sandbox Code Playgroud)
如何修复公式?
以下代码抛出错误消息,我无法弄清楚问题是什么 - 是这个词static,还是const?我究竟做错了什么?
#include <iostream>
using namespace std;
class SampleClass
{
private:
int value;
static int counter;
public:
SampleClass(int i)
{
value = i;
counter++;
}
static int countSomeClass() const
{
return counter;
}
void showValue()
{
cout << value << endl;
}
};
int main()
{
SampleClass test(50);
test.showValue();
test.countSomeClass();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
错误信息:
main.cpp:16:35:错误:静态成员函数static int SampleClass :: countSomeClass()不能有cv-qualifier
static int countSomeClass()const
我对派生类中重新定义和重写函数之间的差异感到困惑.
我知道 - 在C++中,重新定义的函数是静态绑定的,被覆盖的函数是动态绑定的,并且重写了虚函数,并重新定义了非虚函数.
当派生类"重新定义"基类中的方法时,会考虑重新定义.但是当派生类是虚拟的时,它不再重新定义而是覆盖.所以我理解规则的后勤,但我不明白底线.
在下面的示例中,重新定义了SetScore函数.但是,如果我在基类虚拟中设置setScore函数(通过向其添加单词virtual),将覆盖派生类中的setScore.我不明白底线 - 有什么区别.在setScore?
基类:
class GradedActivity
{
protected:
char letter; // To hold the letter grade
double score; // To hold the numeric score
void determineGrade(); // Determines the letter grade
public:
// Default constructor
GradedActivity()
{ letter = ' '; score = 0.0; }
// Mutator function
void setScore(double s)
{ score = s;
determineGrade();}
// Accessor functions
double getScore() const
{ return score; }
char getLetterGrade() const
{ return letter; }
};
Run Code Online (Sandbox Code Playgroud)
派生类: …
我有以下查询:
select distinct a.id, a.name
from Employee a
join Dependencies b on a.id = b.eid
where not exists
(
select *
from Dependencies d
where b.id = d.id
and d.name = 'Apple'
)
and exists
(
select *
from Dependencies c
where b.id = c.id
and c.name = 'Orange'
);
Run Code Online (Sandbox Code Playgroud)
我有两张桌子,比较简单.第一个Employee有一个id列和一个名称列第二个表Dependencies有3列,一个id,一个eid(要链接的员工ID)和名称(apple,orange等).
数据看起来像这个Employee表看起来像这样
id | name
-----------
1 | Pat
2 | Tom
3 | Rob
4 | Sam
Run Code Online (Sandbox Code Playgroud)
依赖
id | eid | Name
--------------------
1 | 1 | Orange …Run Code Online (Sandbox Code Playgroud) 我很难对齐十进制值。我很确定它是右对齐和 set precision/fixed 的组合,但它似乎不起作用。我知道有人就该主题提出了其他问题,但我还没有找到一个明确的解决方案来获取一堆列(要对齐的独特 cout 语句)。
这是我的代码的一部分:
double total_collect, sales, country_tax, state_tax, total_tax;
const double STATE_TAX_RATE = 0.04, COUNTRY_TAX_RATE = 0.02;
// Compute taxes
total_collect = 100;
sales = 100 / 1.06 ;
country_tax = sales * COUNTRY_TAX_RATE;
state_tax = sales * STATE_TAX_RATE;
total_tax = country_tax + state_tax;
//Display
cout << setiosflags(std::ios::right) ;
cout << "Totla Collected: " << setw(7) << "$ " << fixed << setprecision(2) << right << total_collect << endl;
cout << "Sales: " << setw(17) << …Run Code Online (Sandbox Code Playgroud) 似乎在一些软件/编译器上,该pow()功能可以在没有任何数学库的情况下工作.只有<iostream>.但在其他人抱怨.数学函数是否已添加到<iostream>库或其他地方?
在C++中如何从参数值模拟返回值是唯一的?我的代码如下所示 - 现在如果数字的数据类型为int,我希望它作为双出去.
template <class T>
T divide(T number)
{
return number/10;
}
Run Code Online (Sandbox Code Playgroud)
在主要我有这个
divide(5);
divide(2.5);
Run Code Online (Sandbox Code Playgroud)
在2.5的情况下,进入和退出的值将是double类型,因此没有问题,但在5的情况下,它作为int进入,但我需要它不被截断并返回为double类型.
template <class T, Class T1>
T1 divide(T number)
{
return number/10;
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为它在函数中寻找两个参数.
T1 template <class T>
T1 divide(T number)
{
return number/10;
}
Run Code Online (Sandbox Code Playgroud)
这给了我没有存储类或类型说明符的声明 - 当我在T1之前将该单词class添加到该行时,我收到错误消息:function返回不完整的类型.
我有以下声明
char c[] = "Hello";
string c2 = "Hello";
Run Code Online (Sandbox Code Playgroud)
我想比较a)需要多少字节的内存和b)字符长度.我知道字符数组在字符串的末尾添加一个空终止符,而不是字符串数据类型.
运用
cout << "The sizeof of c: " << sizeof(c);
cout << "The sizeof of c2: " << sizeof(c2);
Run Code Online (Sandbox Code Playgroud)
返回6和4,我不知道为什么4而不是5?长度函数如何在这里比较...
当我使用以下代码时
cout << "The sizeof of c: " << sizeof(c);
cout <<"The sizeof of c2: " << c2.length();
Run Code Online (Sandbox Code Playgroud)
我得到6和5 ......但它是否以相同的方式比较长度?谢谢.
我需要创建一个仅提取customer_no列的查询(因为软件限制本身如此,因此我无法在外部进行编码)。但是我需要能够通过create_dt(相反)列对数据进行排序。代码/ SQL限制了我使用以下内容,因为为了对某些数据进行排序,必须将这些数据显示在select语句中。
我无法在其中显示它-有什么办法解决吗?
Select Distinct top 3500 a.customer_no
From T_CUSTOMER a WITH (NOLOCK)
JOIN (Select a1.customer_no From VXS_CUST_TKW a1 WITH (NOLOCK) Where a1.tkw in (141)) as e ON e.customer_no = a.customer_no
Where 1 = 1
order by a.create_dt desc
Run Code Online (Sandbox Code Playgroud) 这是我的班级
class NumberList
{
private:
// Declare a structure for the list
struct ListNode
{
double value[10]; // The value in this node
struct ListNode *next; // To point to the next node
};
ListNode *head; // List head pointer
public:
// Constructor
NumberList()
{ head = nullptr; }
// Destructor
~NumberList();
// Linked list operations
void appendNode(double []);
void insertNode(double []);
void deleteNode(double []);
void displayList() const;
};
Run Code Online (Sandbox Code Playgroud)
这是我的追加功能,我无法让它工作 - 我不断收到错误信息.
void NumberList::appendNode(double num[])
{
ListNode *newNode; // To …Run Code Online (Sandbox Code Playgroud) 我很困惑 - 我有以下代码 - 最小值和最大值是我们的范围值.据我所知,srand函数接受一个值 - 种子值并返回一个伪随机整数.首先什么是伪随机整数?
// Constants
const int MIN = 50;
const int MAX = 450;
// Get the system time.
unsigned seed = time(0);
// Seed the random number generator.
srand(seed);
// Generate two random numbers.
int num1 = MIN + rand() % MAX;
int num2 = MIN + rand() % MAX;
Run Code Online (Sandbox Code Playgroud)
我们还需要初始化时间值吗?我们可以简单地调用时间函数吗?我相信时间函数会返回类似于秒的部分 - 创建随机#?我一般都很困惑如何生成随机#.
谢谢
我之前使用浮点变量编码,从来没有遇到过这个问题.
float a, b, subtotal, stx;
a=15.95;
b=24.95;
subtotal=a+b;
stx=subtotal*.07;
cout << "Item 1: $" << a << endl;
cout << "Item 2: $" << b << endl;
cout << "\nSubtotal: $" <<subtotal<< endl;
cout << "Sales Tax: $" << stx << endl;
cout << "Total: $" << subtotal+stx << endl;
Run Code Online (Sandbox Code Playgroud)
比较严格的前瞻性代码
warning C4305: '=' : truncation from 'double' to 'float'
Run Code Online (Sandbox Code Playgroud)
我理解数据被截断的想法(我也知道你可以f在变量的末尾写入.但是如果变量被声明为float,为什么编译器将文字值解释为双精度,如果它被声明为浮点数.
我查了几张其他的门票而且他们不同于我的询问我似乎无法找到一个解决方案,为什么数据被读作双重如果它被声明为浮点数.
c++ ×9
class ×3
arrays ×2
join ×2
sql ×2
alignment ×1
base ×1
character ×1
const ×1
decimal ×1
derived ×1
double ×1
excel ×1
excel-match ×1
fixed ×1
function ×1
inheritance ×1
int ×1
iomanip ×1
libraries ×1
linked-list ×1
math ×1
mysql ×1
nodes ×1
object ×1
oop ×1
output ×1
overloading ×1
pow ×1
random ×1
seed ×1
size ×1
sql-order-by ×1
static ×1
string ×1
t-sql ×1
templates ×1
time ×1
truncation ×1
vlookup ×1
warnings ×1