repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
strub: enable conditional support
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
torture
/
pr39417.C
blob
b7bbb88b7845634178215a8ea346c7d0acd879c0
1
// { dg-do run }
2
3
#include <vector>
4
5
std::vector <int>
6
sequence(int l, int n)
7
{
8
std::vector <int> ret;
9
for(int i=n;i<=100;i++)
10
{
11
if(i%2==0)
12
{
13
if(l%i==i/2)
14
{
15
int init =l/i-i/2+1;
16
if(init>=0)
17
{
18
for(int j=0;j<i;j++)
19
{
20
ret.push_back(init);
21
init ++;
22
}
23
break;
24
}
25
}
26
}
27
else
28
{
29
if(l%i==0)
30
{
31
int init =l/i-i/2;
32
if(init>=0)
33
{
34
for(int j=0;j<i;j++)
35
{
36
ret.push_back(init);
37
init ++;
38
}
39
break;
40
}
41
}
42
}
43
}
44
return ret;
45
}
46
extern "C" void abort (void);
47
int main()
48
{
49
std::vector<int> res = sequence(18, 2);
50
if (res.size () != 3
51
|| res[0] != 5
52
|| res[1] != 6
53
|| res[2] != 7)
54
abort ();
55
return 0;
56
}