本文整理汇总了C++中Span::addNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ Span::addNumber方法的具体用法?C++ Span::addNumber怎么用?C++ Span::addNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Span
的用法示例。
在下文中一共展示了Span::addNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Span sp = Span(5);
Span sp1 = Span(10000);
Span sp2 = Span(10000);
Span sp3 = Span(10);
Span sp4 = Span(1);
srand(time(NULL));
sp.addNumber(5);
sp.addNumber(3);
sp.addNumber(17);
sp.addNumber(9);
sp.addNumber(11);
std::cout << sp.shortestSpan() << std::endl;
std::cout << sp.longestSpan() << std::endl;
sp1.RandInterval(9000);
std::cout << sp1.shortestSpan() << std::endl;
std::cout << sp1.longestSpan() << std::endl;
sp2.Interval(42, 9000);
std::cout << sp2.shortestSpan() << std::endl;
std::cout << sp2.longestSpan() << std::endl;
sp3.RandInterval(9000);
std::cout << sp3.shortestSpan() << std::endl;
std::cout << sp3.longestSpan() << std::endl;
sp4.addNumber(5);
sp4.addNumber(6);
std::cout << sp4.shortestSpan() << std::endl;
std::cout << sp4.longestSpan() << std::endl;
return (0);
}
示例2: main
int main()
{
srand(std::time(0));
try
{
Span sp = Span(5);
sp.addNumber(5);
sp.addNumber(3);
sp.addNumber(17);
sp.addNumber(9);
sp.addNumber(11);
std::cout << sp.shortestSpan() << std::endl;
std::cout << sp.longestSpan() << std::endl;
Span big(10000);
big.initAll(randNumber);
std::cout << big.shortestSpan() << std::endl;
std::cout << big.longestSpan() << std::endl;
Span sp2(1);
std::cout << sp2.shortestSpan() << std::endl;
}
catch (std::exception & e)
{
std::cout << e.what() << std::endl;
}
}
示例3: main
int main()
{
std::srand(time(0));
Span sp = Span(10000);
try
{
while (1)
sp.addNumber(rand());
}
catch(std::exception &e)
{
std::cout << e.what() << std::endl;
}
std::cout << sp.shortestSpan() << std::endl;
std::cout << sp.longestSpan() << std::endl;
}