#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>
double gen(double dS) //Function for a random double variable
{
double dx=0;
dx=rand()%200+1;
dS=dx/100;
return(dS);
}
int main()
{
double dZahl=0;
double dTokens=1;
srand((unsigned)time(NULL));
double dSummand=0;
int iGame=0;
for(;;)
{
printf("Deine Tokens:%.2lf\n", dTokens); //This doesn't really matter
printf("Was m%cchtest du tun?\n[1]:Generiere Tokens\n[2]:Spiele ein Minigame\n", 148);
fflush(stdout);
scanf("%d", &iGame);
fflush(stdin);
switch (iGame)
{
case 1:
{
gen(dSummand); //function in use
dTokens=dTokens+dSummand;
printf("\nDu hast %.2lf Tokens generiert!\n", dSummand); //the output of the value
fflush(stdout);
}
break;
}
}
getch();
}
的問題是,dSummand沒有得到來自DS中的值。有誰知道問題是什麼,因爲我試圖解決它,但我無法弄清楚。功能參數被稱爲
我想獲得一個隨機函數的雙重值爲我的程序。我認爲它會這樣工作,但不幸的是它沒有。
請您標題改成這樣的問題反映了問題的主題,而不是需要幫助的請求。另外我懷疑[tag:eclipse]是正確的標籤。 http://stackoverflow.com/help/how-to-ask –