Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
irc: freenode.net in #torgdevs
// Funkcja obliczająca wartość ciągu Fibonacciego - wersja optymalizowana.
// Tym razem wprowadzilismy dwa parametry:
// n - numer liczby fibonacciego
// fn1 - wartość poprzeniego wyrazu
int fibonacci_2(int n, int &fn1)
{
// Pomocnicze zmienne lokalne
int tf;
// warunek zakończenia rekurencji
if (n == 2)
{
fn1 = 1;
return 1;
}
else if (n == 1)
{
fn1 = 0;
return 1;
}
// jeśli nie został spełniony, obliczamy wartość funkcji
else
{
tf = fibonacci_2(n-2, fn1);
fn1 += tf;
return tf + fn1;
}
}
Ostatnio zmieniony przez Ilufus Knight : 25-11-2016, 18:08
int fx = 0;
int fibonacci_2(int n, int fn1)
{
fx = fn1;
// Pomocnicze zmienne lokalne
int tf;
// warunek zakończenia rekurencji
if (n == 2)
{
fx = 1;
return 1;
}
else if (n == 1)
{
fx = 0;
return 1;
}
// jeśli nie został spełniony, obliczamy wartość funkcji
else
{
tf = fibonacci_2(n - 2, fx);
fx += tf;
return tf + fx;
};
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:layout_height="wrap_content" >
<!--timeLayout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/timeLayout"
android:paddingLeft="16dp"
android:gravity="center"
android:layout_below="@+id/plusesLayout"
android:orientation="horizontal"
android:paddingRight="16dp">
<EditText
android:layout_width="wrap_content"
android:layout_height="33dp"
android:inputType="number"
android:text="0"
android:ems="2"
android:id="@+id/minutes"
android:background="@drawable/back"
android:gravity="center"
android:textCursorDrawable="@null" />
<TextView
android:layout_width="3dp"
android:layout_height="23dp"
android:text=":"
android:ems="2"
android:clickable="false"
android:id="@+id/myTextView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="33dp"
android:inputType="number"
android:text="0"
android:ems="2"
android:id="@+id/tensOfSeconds"
android:background="@drawable/back"
android:gravity="center"
android:textCursorDrawable="@null" />
</LinearLayout>
<!--minusesLayout -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:layout_below="@+id/timeLayout"
android:orientation="horizontal"
android:paddingRight="16dp"
android:id="@+id/minusesLayout"
android:layout_centerHorizontal="true">
<Button
android:text="-"
android:id="@+id/secondsMinus"
android:layout_width="43dp"
android:layout_height="33dp"
android:layout_weight="0.01"
android:textSize="10sp" />
</LinearLayout>
<!-- plusesLayout-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingRight="16dp"
android:layout_centerHorizontal="true"
android:id="@+id/plusesLayout">
<Button
android:text="+"
android:id="@+id/secondsPlus"
android:layout_width="43dp"
android:layout_height="33dp"
android:layout_weight="0.01"
android:textSize="10sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:paddingRight="16dp"
android:layout_centerHorizontal="true"
android:id="@+id/menuLayout">
<Button
android:text="START"
android:id="@+id/start"
android:layout_width="43dp"
android:layout_height="33dp"
android:layout_weight="0.05"
android:textSize="10sp" />
<Button
android:text="STOP"
android:id="@+id/stop"
android:layout_width="43dp"
android:layout_height="33dp"
android:layout_weight="0.01"
android:textSize="10sp" />
<Button
android:text="PAUSE"
android:id="@+id/pause"
android:layout_width="43dp"
android:layout_height="33dp"
android:layout_weight="0.01"
android:textSize="10sp" />
</LinearLayout>
</RelativeLayout>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#ffffff" />
<stroke android:width="1dip" android:color="#000000"/>
</shape>
android:layout_centerInParent="true"
public class RegisterModel {
Connection connection;
public void register(String name) throws SQLException {
PreparedStatement pst = null;
String query = "INSERT INTO Test (name) VALUES (?)";
try{
pst = connection.prepareStatement(query);
pst.setString(1, name);
pst.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
System.err.print( e.getClass().getName() + ": " + e.getMessage());
} finally {
if (pst != null) {
pst.close();
}
}
}
}
@FXML
private TextField txtNewUserName;
public void registerBtn(ActionEvent event){
try {
register(txtNewUserName.getText());
} catch (SQLException e) {
e.printStackTrace();
}
}
Ostatnio zmieniony przez hefalump : 29-11-2016, 15:09
Connection connection = new Connection();
oraz
private TextField txtNewUserName = new TextField();
Ostatnio zmieniony przez szulak : 29-11-2016, 15:11
public void deleteMeal() {
productData selection = tableProduct2.getSelectionModel().getSelectedItem();
String name = String.valueOf(selection.getName());
String db = String.valueOf("uid" + userID + "date" + simpleDate.format(new Date()));
try {
PreparedStatement pst = conn.prepareStatement("DELETE FROM " + db + "WHERE name =" + name);
pst.executeUpdate();
}catch (SQLException e){
e.printStackTrace();
}
if(selection != null){
tableProduct2.getItems().remove(selection);
}
updateSummary();
}
Kryptolog i Cyberbezpiecznik
Ostatnio zmieniony przez hefalump : 05-12-2016, 23:37
Aktualnie 2 użytkowników przegląda ten temat. (0 użytkowników i 2 gości)
Zakładki