Results 1 to 25 of 25
Thread: C++
Hybrid View
-
8th February 2010 21:20 #1
C++
Dev c++, . ( )
, n n- .
( , ) , . !
-
8th February 2010 21:44 #2
, .
, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
8th February 2010 21:45 #3Registered User
Join Date: Dec:2007
Location: Sofia
Posts: 366
-
8th February 2010 21:52 #4
#include <iostream>
using namespace std;
int main()
{
int n;
if(n=0)return 0;
if(n=1)return 1;
if(n>1)return n>1;
else return n=n-1+n-2;
cout << n << endl;
system ("pause");
return 0;
}
"", , 1 , system pause.
, .
!
-
8th February 2010 22:07 #5Registered User
Join Date: Dec:2007
Location: Sofia
Posts: 366
-
8th February 2010 22:10 #6
, - . for (int i=1;i>=n .. Cout-a ,
-
8th February 2010 22:21 #7
... - 2. n3=n2+n1 n1,n2,n3,n4,n5...nn.
-
9th February 2010 10:39 #8
...
:
1) n ...
cin<<n;
2) return 0; 0 .. if(n=0)return 0;
n 0 - ...
btw, ...
3) . "arr" n e "" .
3.1. rr[0] = 0; arr[1] = 1; //10 to ined
3.2. :
3.2. O arr[n-1]; /* , */Code:for(int i = 2; i < n; i++) { arr[i] = arr[i-1] + arr[i-2]; // 1-2?! }
4) return 0; - Main() , main(), (.. ) 0.
: ""?! ...Last edited by Kaspirtov; 9th February 2010 at 13:02.
" , , , , ."
-
9th February 2010 11:12 #9
-
9th February 2010 12:19 #10
-
9th February 2010 13:02 #11, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
9th February 2010 11:17 #12
n .Code:long Fib( int n) { switch (n) { case 0: return 0; case 1: case 2: return 1; default: { long a = 1; long b = 2; for (int i = 3; i < n; i++) { long c = a + b; a = b; b = c; } return b; } } }AMD Phenom II X4 980 Black @4GHz with 1.425v |GA-MA790FX-UD5P| Prolimatech Megahalems + Noctua NF-S12B-FLX |EVGA GeForce GTX 1060 SSC 6GB ACX 3.0 | 42GB G.Skill F2-8000CL5D-4GBPQ | 1TB + 640GB WD Black | Seasonic X750 Gold | CM 690 II Advanced Black | Logitech Wave Pro | Edifier R1850DB
-
9th February 2010 12:38 #13
, - 0, arr[1] 1
ASRock B85 Pro4, Pentium G3240, DD3 8GB/1333MHz, 120GB SSD + 1TB + 640GB HDD
Gigabyte GV-R657OC-1GI, CM B500, ASUS 24B1S1, LCD SAMSUNG SM931BW, 173
-
9th February 2010 12:47 #14
-
9th February 2010 13:20 #15
,
var1 = 9 var2 = 4
1: var1 = var1 + var2 9+4=13
2: var2 = var1 var2 13-4=9
3: var1 = var1 var2 13-9=4AMD Phenom II X4 980 Black @4GHz with 1.425v |GA-MA790FX-UD5P| Prolimatech Megahalems + Noctua NF-S12B-FLX |EVGA GeForce GTX 1060 SSC 6GB ACX 3.0 | 42GB G.Skill F2-8000CL5D-4GBPQ | 1TB + 640GB WD Black | Seasonic X750 Gold | CM 690 II Advanced Black | Logitech Wave Pro | Edifier R1850DB
-
9th February 2010 23:59 #16
#include <iostream>
using namespace std;
int fibona4i (int n) {
if ((n==1)||(n==2)) return 1;
return fibona4i(n-2)+fibona4i(n-1);
}
int main () {
int n;
cout <<"Vuvedete koe 4islo na Fibona4i tursim: ";
cin >>n;
cout <<n<<"-toto 4islo na Fibona4i e: "<<fibona4i (n)<<endl;
system ("pause");
return 0;
}
,Q9550@4.3GHz | 3D Mark 06 GTX 280 | 3D Mark 06 4870x2 | 3D Mark 06 5850
Asrock P67 Pro3|Intel Core i7 2600k|A-Data 2X2GB DDR3 @ 1866MHz 8-8-8-24|Sapphire 6850|WD Caviar Black 750GB Sata III 64MB|Coolermaster RealPower M700|Coolermaster HAF 922|Samsung SM P2350|A4Tech X755FS|Logitech Wave Keyboard
-
10th February 2010 00:04 #17
-
10th February 2010 00:59 #18
-
10th February 2010 01:06 #19Banned
Join Date: Nov:2007
Location: Sofia
Posts: 1,400
Code:// Fib.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <conio.h> using namespace std; long Fib(long x) { if (x <= 1) return 1; return Fib(x - 1) + Fib(x - 2); } int _tmain(int argc, _TCHAR* argv[]) { long number = 0; cout << "Enter a number: "; cin >> number; cout << "Fib of " << number << " is : " << Fib(number); cout << "\n"; system("PAUSE"); }
Code:// Fib.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <conio.h> #include <math.h> #include <time.h> using namespace std; const long double inverseSqrt5 = 0.44721359549995793928183473374626; const long double phi = 1.6180339887498948482045868343656; long Fib(long x) { if (x <= 1) return 1; return Fib(x - 1) + Fib(x - 2); } long UltraFastFib(long n) { return (int)floor(pow(phi, n) * inverseSqrt5 + 0.5); } long calculate_method(long (*ptr)(long), int number) { clock_t start, finish; long result = 0; start = clock(); result = (*ptr)(number); finish = clock(); int seconds = (finish - start)/CLOCKS_PER_SEC; cout << "Method took " << seconds << " secodns." << endl; return result; } int _tmain(int argc, _TCHAR* argv[]) { long number = 0; cout << "Enter a number: "; cin >> number; cout << "Calculating Fib using resursive method ;)"<< endl; cout << "Result of fib(" << number << ") is " << calculate_method(&(Fib),number) << endl; cout << "Calculating Fib using ultra fast method ;)"<< endl; cout << "Result of fib(" << number << ") is " << calculate_method(&(UltraFastFib),number) << endl; system("PAUSE"); }Last edited by PhrozenOne; 10th February 2010 at 01:46.
-
10th February 2010 05:40 #20, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
11th February 2010 16:31 #21Registered User
Join Date: Sep:2009
Location:
Posts: 115
. , 5-6 .
:
Code:#include <iostream> using namespace std; int main() { int a,n,f=0,g=1,s=0; cin>>n; for(a=0;a<n-1;a++){ s=g; g=g+f; f=s; } cout<<s<<"\n"; system("PAUSE"); }
-
17th February 2010 00:06 #22Q9550@4.3GHz | 3D Mark 06 GTX 280 | 3D Mark 06 4870x2 | 3D Mark 06 5850
Asrock P67 Pro3|Intel Core i7 2600k|A-Data 2X2GB DDR3 @ 1866MHz 8-8-8-24|Sapphire 6850|WD Caviar Black 750GB Sata III 64MB|Coolermaster RealPower M700|Coolermaster HAF 922|Samsung SM P2350|A4Tech X755FS|Logitech Wave Keyboard
-
17th February 2010 11:51 #23
Join Date: Sep:2005
Location: Sofia
Posts: 18,517
, 50- 2^50
.
-
22nd October 2016 20:01 #24
-
23rd October 2016 11:23 #25ASRock B85 Pro4, Pentium G3240, DD3 8GB/1333MHz, 120GB SSD + 1TB + 640GB HDD
Gigabyte GV-R657OC-1GI, CM B500, ASUS 24B1S1, LCD SAMSUNG SM931BW, 173




Reply With Quote
. 
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in