我不确定我的逻辑中的错误是什么.样本输出:
How many terms of the Fibonacci Sequence do you wish to compute?
1
1
1
--How many terms of the Fibonacci Sequence do you wish to compute?
5
5
5
5
5
5
5
Run Code Online (Sandbox Code Playgroud)
它为什么这样做?
// Recursive Fibonacci Sequence
#include <iostream>
using namespace std;
double fib(double number);
int main(void) {
double number;
cout << "How many terms of the Fibonacci Sequence do you wish to compute?" << endl;
cin >> number;
for(int i = 0; i <= number; ++i) …Run Code Online (Sandbox Code Playgroud) 它总是输出'0'的区域.我无法想象如何在int r计算面积方面工作.
// Define a class and use it to test out some math stuff
#include <iostream>
#include <cmath>
using namespace std;
class Circle {
public:
// function that calculates the area of a circle
float circle_area(int r) {
area = 3.14 * (r*r);
return area;
} // end function circle_area
void display_msg() {
cout << "Area: " << circle_area(r) << endl;
} // end function display_msg
private:
float area;
int r;
}; // end class Circle
int …Run Code Online (Sandbox Code Playgroud) 此代码直接从Kotlin公开的Wiki中提取,但不起作用。奇怪而令人沮丧的是,我无法实现它,因为我有一个很棒的项目,需要使用RDBMS。我想念什么?坏了吗
import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.Table
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.selectAll
fun main(args: Array<String>) {
Database.connect("jdbc:h2:mem:test", driver = "org.h2.Driver")
transaction {
logger.addLogger(StdOutSqlLogger)
val stPeteId = Cities.insert {
it[name] = "St. Petersburg"
} get Cities.id
println("Cities: ${Cities.selectAll()}")
}
}
// Table definition
object Cities : Table() {
val id = integer("id").autoIncrement().primaryKey()
val name = varchar("name", 50)
}
// Entity definition
data class City(
val id: Int,
val name: String
)
Run Code Online (Sandbox Code Playgroud)
在Intellij中运行时,我收到以下错误消息:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". …Run Code Online (Sandbox Code Playgroud) 我有一个'^'分隔的产品ID号列表,我需要只获取产品ID号,然后用它来查询SQL数据库.产品ID号存储在$ _SESSION哈希中.例如:
SKUS: jpn18726^gr172645^123746^17246^eu186726^...
我能想到的代码是这样的:
$prodmat = $_SESSION["product"];
if(preg_match("(\d+)(^\s*\d+)*", $prodmat) {
$stmt = "select shipcode from materials where material='???'";
}
Run Code Online (Sandbox Code Playgroud)
基本上,我想从'^'分隔列表中提取产品ID号,然后使用产品ID号查询DB.