i wrote a program that plays this game we do in math class. you are given five numbers, say 5 7 3 9 and with thoes number you must get to a fith number say 11. so you think about it and say 7+3=10, 10/5=2, 2+9=11. so i wrote this program with a 3 funtions i made. i taught myself c++ over the summer and it is my first language so im not that good. any way it seemed that my computer skiped over the funtions. just ignored them. a simple example of what i was doing.when i should have been doing thisCode:main(){ int c; funtion(); cout<<c<<endl; } funtion(){ c=1; return(); }so i fixed this but now i dont get any out put at the end i looked for bout 3 hours for something wrong i cant find anything. could some one please help me. thank you very much. and here is my codeCode:main(){ int c; c=funtion(); } funtion(){return 1; }
if someone could give me a nudge it the right diretion that would be great. thank you very muchCode:#include <iostream> #include <math.h> using namespace std; float comp (float a, float b, int t); int perm (int varo, int ea, int eb, int ec, int ed); int computation (float sa, float sb, float sc, float sd, float se); int main(){ float na; float nb; float nc; float nd; float ne; int k; int j; int l; int m; int chance; int ea = 0; int eb = 0; int ec = 0; int ed = 0; float pa = 0; float pb = 0; float pc = 0; float pd = 0; cout<<"type in the first four numbers press enter after each one"<< endl; cin>> na; cin>> nb; cin>> nc; cin>> nd; cout<<"now enter the number you want to get"<< endl; cin>> ne; k = 0; while (k<=4){ k ++; chance = perm (k, ea, eb, ec, ed); if (chance==1){ ea = 1; pa = na; k=1; }; if (chance==2){ eb = 1; pb = na; k=2; }; if (chance==3){ ec = 1; pc = na; k=3; }; if (chance==4){ ed = 1; pd = na; k=4; }; j = 0; while(j<=4){ j ++; chance = perm (j, ea, eb, ec, ed); if (chance==1){ ea = 1; pa = nb; j=1; }; if (chance==2){ eb = 1; pb = nb; j=2; }; if (chance==3){ ec = 1; pc = nb; j=3; }; if (chance==4){ ed = 1; pd = nb; j=4; }; l = 0; while(l<=4){ l ++; perm (l, ea, eb, ec, ed); if (chance==1){ ea = 1; pa = nc; l=1; }; if (chance==2){ eb = 1; pb = nc; l=2; }; if (chance==3){ ec = 1; pc = nc; l=3; }; if (chance==4){ ed = 1; pd = nc; l=4; }; m = 0; while (m<=1){ m++; if (ea=0){ pa=nd; ea=1; } else if(eb=0){ pb=nd; eb=1; } else if (ec=0){ pc=nd; ec=1; } else if (ed=0){ pd=nd; ed=1; }; computation (pa, pb, pc, pd, ne); }; }; }; }; cout <<"thanks"<<endl; cin.get(); }; int computation (float sa, float sb, float sc, float sd, float se){ float c = 0; int thinga = 0; while (thinga <= 8){ thinga ++; c = comp (sa, sb, thinga); float stepa = c; int thingb = 0; while(thingb <= 8){ thingb ++; c = comp (c, sc, thingb); float stepb = c; int thingc = 0; while (thingc <= 8){ c ++; c = comp (c, sd, thingc); float stepc = c; if(c == se){ cout << sa<< "?"<< sb<< "="<< stepa <<endl; cout << stepa<< "?"<< sc<< "="<< stepb <<endl; cout << stepb<< "?"<< sd<< "="<< stepc <<endl; cout << " " <<endl; }; }; }; }; cout <<"theend"<<endl; return 0; }; float comp (float a, float b, int t){ float c; if(t==1){ c = a + b; }; if(t==2){ c = a - b; }; if(t==3){ c = a * b; }; if(t==4){ c = a / b; }; if(t==5){ c = pow(a, b); }; if(t==6){ c = b - a; }; if(t==7){ c = b / a; }; if(t==8){ c = pow(b, a); }; return c; }; int perm (int varo, int ea, int eb, int ec, int ed){ int chance; if (varo==1){ if (ea==1){ varo++; }; if (ea==0){ chance=1; }; }; if (varo==2){ if (eb==1){ varo++; }; if (eb==0){ chance=2; }; }; if (varo==3){ if (ec==1){ varo++; }; if (ec==0){ chance=3; }; }; if (varo==4){ if (ed==1){ varo++; }; if (ed==0){ chance=4; }; }; return chance; };



LinkBack URL
About LinkBacks



. my compiler did not pick up on that,is there any way i could make it do that?sadly though my program still dose not work
