Laravel如何在"routes"目录中的console.php文件中使用$ this-> comment()方法,而Artisan :: command()是一个静态方法?
<?php
use Illuminate\Foundation\Inspiring;
Artisan::command('inspire', function() {
$this->comment(Inspiring::(quote));
})->describe('Display an inspiring quote');
Run Code Online (Sandbox Code Playgroud) 我们得到了我想出解决方案的问题。有人可以帮我确定给定解决方案的时间复杂度吗?应该是 O(n) 还是 O(n^2)?在我看来,它应该是 O(n)。
问题
编写一个程序,按照以下给定的条件打印数组元素的总和。
如果数组依次为 6 和 7,则忽略 6 和 7 之间的数字,并考虑其他数字进行总和计算。
Eg1) 数组元素 - 10,3,6,1,2,7,9 O/P: 22 [即 10+3+9]
Eg2) 数组元素 - 7,1,2,3,6 O/P:19
Eg3) 数组元素 - 1,6,4,7,9 O/P:10
解决方案
outer: for (i = 0; i < elementsCount; ++i) {
if (arr[i] == 6) {
int sumBetweenBounds = arr[i];
for (j = i + 1; j < elementsCount; ++j) {
if (arr[j] == 7) {
i = j;
continue outer;
}
sumBetweenBounds += arr[j];
}
sum …Run Code Online (Sandbox Code Playgroud)