CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Counting

  1. #1
    Join Date
    Oct 2007
    Posts
    25

    Counting

    Below is a piece of my program, i have printed out all the expressions. As the number of expressions it prints is incredibly large (over 5,000) and takes time i want to be able to count the number of expressions it will print instead of actually printing all the expressions.

    Can anyone help?

    Code:
    newCalcWaiting=true; // to deal with a later possible equality
                             i = iva_level(level);
                             for (j = iva_level(level+1) ; j < iva_level(level+2) ; j++)
                                 {if (i == highV[level])
                                    {// ignore the first of the contributors to calculation
                                     i++;
                                    }
                                 if (i == lowV[level])
                                    {// ignore the second of the contributors to calculation
                                     i++;
                                    }
                                 if (newCalcWaiting && (sorted[i]<=thiscalc 
                                                        || iva_level(level+1)<=i ) )
                                    {// insert the new calculation into the next level
                                     sorted[j]=thiscalc;
                                     expression[j]=newform;
                                     newCalcWaiting=false;
                                     System.out.println("expression =  " + expression[j]);
                                     System.out.print(sorted[j]);
                                     System.out.println();
                                     
                                    }

  2. #2
    Join Date
    Jan 2006
    Posts
    90

    Re: Counting

    Instead of this:

    Code:
    System.out.println("expression =  " + expression[j]);
    System.out.print(sorted[j]);
    System.out.println();
    just make up a variable (maybe int expressionCounter) that you increment each time. Then at the end of the for loop, you can use that number as a counter for how many expressions you've done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured