gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
intMult.C
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 // g++ intMult.C -o intMult
18 
19 #include "Tree.H"
20 
21 int main (int argc, char *argv[]){
22 
23 Tree rootNode;
24 
25 int N=3;
26 int count=(uint)pow(2.0,3.0);
27 int vals[count];
28 int output[count];
29 
30 for (int i=1;i<=count;i++)
31  vals[i]=i;
32 
33 rootNode.addLayers(N,vals);
34 
35 cout<<"tree results:\n";
36 for (int i=1;i<=count;i++){
37  output[i]=rootNode.multiply(i);
38  cout<<output[i]<<endl;
39 }
40 
41 
42 //brute force
43 cout<<"tree results:\n";
44 for (int i=1;i<=count;i++){
45  int val=1;
46  for (int j=1; j<i; j++)
47  val*=j;
48  for (int j=i+1; j<=count; j++)
49  val*=j;
50  cout<<val<<endl;
51 }
52 
53 return 0;
54 }
int N
int main(int argc, char *argv[])
Definition: intMult.C:21
unsigned int uint
Definition: Box.H:28
Definition: Tree.H:26
int multiply(uint whichNode)
Definition: Tree.H:73
void addLayers(uint N, int *vals, uint minimumIn=1)
Definition: Tree.H:47
gtkIOStream: /tmp/gtkiostream/include/mffm/possible.future.additions/examples/intMult/intMult.C Source File
GTK+ IOStream  Beta