urgent!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jing
    New Member
    • Sep 2006
    • 2

    urgent!

    I need help with c program in combinatorics! I has lost file, and i forget what did i write last time, but i try to write some, so following is my code:
    /* Program to calculate mutiplication for triple of integer that sum up to a total_length */

    #include <stdio.h>
    #define TOTAL_LENGTH 100

    int main(void)
    {
    float x,y,z,total_len gth;
    float orig_x,orig_y,o rig_z;
    int cnt=0,i,j,k,n;
    int status;

    printf("This program to calculate mutiplication for triple of integer that sum up to a total_length");

    do {
    printf("Enter an number x:");
    status = scanf("%f",&x);
    printf("Enter an number y:");
    status = scanf("%f",&y);
    printf("Enter an number z:");
    status = scanf("%f",&z);
    }
    orig_x=x;
    orig_y=y;
    orig_z=z;
    total_length=10 0

    for(i=0;i<=n;++ i)
    for(j=0;j<=n;++ j)
    for(k=0;j<=n;++ k)
    if(i*x+j*y+k*z= =total_length) {
    printf("\n Calculating the program\n\n");
    printf("\ni*x+j *y+k*z=100\n\n" );
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    What happens when you compile/run it?

    You seem to detect the answer but not output the values of the variables concerned

    Comment

    • jing
      New Member
      • Sep 2006
      • 2

      #3
      Hi:
      Actually Last time it runs, but seem vaid. But I can't remember what other staff I write. It is a combitorirics. mautiple of three defferent numbers to sum up to a total length. for eg: 1 integer times 1 number+1 integer times another number+1 integer times another defference integer.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        The only error I can see is that you don't seem to assign a value to n and that when you have found a solution you do not print out the values of the variables involved for that solution.

        Comment

        Working...