#include int main () { int i,j,k,low_roll, low_stat, sum, stat_sum, points; int dice[4],stat[6]; do { srand ((unsigned) time(NULL)); for(low_stat=18,stat_sum=i=0;i<6;stat_sum+=stat[i],i++) { printf("\nRolls:\t"); for(low_roll=6,sum=j=0;j<4;sum+=dice[j],j++) { // "Rolls" 4d6 and Sums dice[j] = rand()%6+1; printf("%d ",dice[j]); if(dice[j] < low_roll) low_roll = dice[j]; // Keeps Track of Lowest Roll for current set of 4d6 } sum-=low_roll; // For the purposes of D&D Character Creation, only the best 3 rolls are counted stat[i]=sum; if(stat[i] < low_stat) low_stat = stat[i]; // Keeps Track of Lowest Stat printf("\tStat:\t%d",stat[i]); } printf("\n\t\t\tAvg:\t%lf\n",(double) stat_sum/i); if(low_stat>=10) points=2; // Costs 2 to buy 8 up to 10 FIRST else if(low_stat==9) points=1; // Costs 1 to buy 8 up to 9 else points=0; for(i=0;i<6;i++) { if(stat[i]<=10) ; else if(stat[i]==11) points+=1; else if(stat[i]==12) points+=2; else if(stat[i]==13) points+=3; else if(stat[i]==14) points+=5; else if(stat[i]==15) points+=7; else if(stat[i]==16) points+=9; else if(stat[i]==17) points+=12; else if(stat[i]==18) points+=16; } printf("\nPoint System Equivalent:\t%d\n",points); printf("\nEnter 0 to exit:\t"); scanf("%d",&k); fflush(stdin); } while(k!=0); return 0; }