User
Pass
2FA
 
 

Problema C

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Man and society, art and culture, free time -> School & Education -> Homework zone
Author Message953
Fough

[Nutella Lover]



Status: Offline
(since 13-12-2019 12:16)
Joined: 12 Dec 2012
Posts: 1046, Topics: 193
Location: Gotham

Reputation: 393.9
Votes: 153

   
Post Posted: 28-10-2014, 02:17:08 | Translate post to: ... (Click for more languages)

nu stiu daca e sectia buna -...daca nu e ok fac topic si la IT...
fac C de o luna si am un profesor care nu explica nimic...NIMIC!(il intreb unde e gresit si zice ca trebuie sa gasesc singur -)...so....la C/C++ ma pricepeam si totul ok...in C nu-mi iese nimic...am problema sa fac combinari de n luate cate k folosind un subprogram(functie) care calculeaza aranjamentele(combinari=aranjamente/k factorial).programul este:
Code:
#include<stdio.h>
#include<conio.h>
double aranjamente(int n,int k);
int main(){
int x,y,i;
double fact,a;
printf("\nIntroduceti primul numar: ");
scanf("%d",&x);
printf("\nIntroduceti al doilea numar: ");
scanf("%d",&y);
for(i=2,a=1;i<=y,i++){
a=a*i;}
fact=aranjamente(x,y);
printf("\nNumarul de combinari este: %d\n ",fact/a);
getch();}
double aranjamente(int n,int k){
double f,g;
int i,j;
for(i=2,f=1;i<=n;i++)
f=f*i;
for(J=2,g=1;j<=(n-k),j++)
g=g*j;
return (f/g);}

m-am uitat la el o ora dupa greseli in logica si nu gasesc -...nu da erori(daca sunt,am copiat eu gresit mai sus)...problema este ca fiecare factorial mi-l da egal cu 0...any help?



0 0
  
Back to top
View user's profile Send private message
tudor1297

[shefu' la luptatori]



Status: Offline
(online 1 day ago)
Joined: 11 Sep 2012
Posts: 2565, Topics: 193
Location: Bucuresti

Reputation: 361.9
Votes: 250

         
Post Posted: 28-10-2014, 02:28:48 | Translate post to: ... (Click for more languages)

Ah pai n.ai initializat f si g. Daca le declari si le lasi asa o sa aiba ultima valoare salvata in baza de date, la time e 0.

Deci dupa ce le declari tre sa scrii f=1;g=1;

Inca o chestie, vezi ca factorialul ala e un numar foarte made
10! Deja e vreo 3 milioane
Nu cumva trebuie sa afisezi numarul ala modulo ceva?




[RO]Warrior Fury PvE Guide 5.4.8

[EN]Warrior Fury PvE Guide 5.4.8

0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
Fough

[Nutella Lover]



Status: Offline
(since 13-12-2019 12:16)
Joined: 12 Dec 2012
Posts: 1046, Topics: 193
Location: Gotham

Reputation: 393.9
Votes: 153

   
Post Posted: 28-10-2014, 02:44:49 | Translate post to: ... (Click for more languages)

tudor1297 wrote:
Ah pai n.ai initializat f si g. Daca le declari si le lasi asa o sa aiba ultima valoare salvata in baza de date, la time e 0.

Deci dupa ce le declari tre sa scrii f=1;g=1;

Inca o chestie, vezi ca factorialul ala e un numar foarte made
10! Deja e vreo 3 milioane
Nu cumva trebuie sa afisezi numarul ala modulo ceva?


uhm...
Quote:
for(i=2,f=1;i<=n;i++)
f=f*i;
for(J=2,g=1;j<=(n-k),j++)
g=g*j;

am incercat sa le initializez si inainte si da same shit...le-am pus double...oricum..nu marimea e problema..ca le testez pe numere mici daca merge...intrebarea era de ce nu merge...



0 0
  
Back to top
View user's profile Send private message
tudor1297

[shefu' la luptatori]



Status: Offline
(online 1 day ago)
Joined: 11 Sep 2012
Posts: 2565, Topics: 193
Location: Bucuresti

Reputation: 361.9
Votes: 250

         
Post Posted: 28-10-2014, 03:04:54 | Translate post to: ... (Click for more languages)

Ah nu am vazut aia -
Vezi ca double e pentru numere cu zecimale, s.ar putea sa.ti faca probleme

Pune.le int sau long pe toate, vezi poate merge

Altfel nu stiu, nu vad nicio greseala. As baga codul intr.un compilator, dar sunt pe telefon -




[RO]Warrior Fury PvE Guide 5.4.8

[EN]Warrior Fury PvE Guide 5.4.8

0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
Fough

[Nutella Lover]



Status: Offline
(since 13-12-2019 12:16)
Joined: 12 Dec 2012
Posts: 1046, Topics: 193
Location: Gotham

Reputation: 393.9
Votes: 153

   
Post Posted: 28-10-2014, 19:45:38 | Translate post to: ... (Click for more languages)

tudor1297 wrote:
Ah nu am vazut aia -
Vezi ca double e pentru numere cu zecimale, s.ar putea sa.ti faca probleme

Pune.le int sau long pe toate, vezi poate merge

Altfel nu stiu, nu vad nicio greseala. As baga codul intr.un compilator, dar sunt pe telefon -

a mers cu long la toate -...jesus...mersi - (i-o fi fost atat de greu profului sa-mi spuna ca trebuie sa le pun long si nu double - ?)



0 0
  
Back to top
View user's profile Send private message
tudor1297

[shefu' la luptatori]



Status: Offline
(online 1 day ago)
Joined: 11 Sep 2012
Posts: 2565, Topics: 193
Location: Bucuresti

Reputation: 361.9
Votes: 250

         
Post Posted: 28-10-2014, 20:11:58 | Translate post to: ... (Click for more languages)

Nici nu inteleg de ce se mai face C la facultate -
E un limbaj de programare antic, nu prea il mai foloseste nimeni -




[RO]Warrior Fury PvE Guide 5.4.8

[EN]Warrior Fury PvE Guide 5.4.8

0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
Fough

[Nutella Lover]



Status: Offline
(since 13-12-2019 12:16)
Joined: 12 Dec 2012
Posts: 1046, Topics: 193
Location: Gotham

Reputation: 393.9
Votes: 153

   
Post Posted: 28-10-2014, 20:47:47 | Translate post to: ... (Click for more languages)

in "teorie"...e limbajul care are cele mai multe ramuri comune cu toate restul si daca-l intelegem pe asta ne va fi usor sa intelegem orice alt limbaj (bullshit)


0 0
  
Back to top
View user's profile Send private message
Zohlomg

[DEFIANCE]



Status: Offline
(online 3 weeks ago)
Joined: 11 Feb 2010
Posts: 20868, Topics: 690
Location: ~Romania

Reputation: 8860.7
Votes: 768

 
Post Posted: 03-11-2014, 17:21:02 | Translate post to: ... (Click for more languages)

Rezolvat.
0 0
  
Back to top
View user's profile Send private message

  Topic locked


Topic is closed, you cannot post any messages in it anymore

Locked by Zohlomg, 03 November 2014 16:21



 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Man and society, art and culture, free time -> School & Education -> Homework zone  


The time now is 25-01-2020, 14:28:09
Copyright info

Based on phpBB ro/com

 
 
 







I forgot my password


This message appears only once, so
like us now until it's too late ! :D
x