blob: 7af4e3de2d0bdc43cd12916d3788db83a51809ce [file] [log] [blame]
Caroline Tice8607f032011-01-29 00:19:53 +00001//===-- main.cpp ------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include <cstdlib>
11#include <string>
12#include <fstream>
13#include <iostream>
14
15int
16product (int x, int y)
17{
18 int result = x * y;
19 return result;
20}
21
22int
23sum (int a, int b)
24{
25 int result = a + b;
26 return result;
27}
28
29int
30strange_max (int m, int n)
31{
32 if (m > n)
33 return m;
34 else if (n > m)
35 return n;
36 else
37 return 0;
38}
39
40int
41foo (int i, int j)
42{
43 if (strange_max (i, j) == i)
44 return product (i, j);
45 else if (strange_max (i, j) == j)
46 return sum (i, j);
47 else
48 return product (sum (i, i), sum (j, j));
49}
50
51int
52main(int argc, char const *argv[])
53{
54
55 int array[3];
56
57 array[0] = foo (1238, 78392);
58 array[1] = foo (379265, 23674);
59 array[2] = foo (872934, 234);
60
61 return 0;
62}