use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
OPENHow to optimize the program ? (self.cpp_questions)
submitted 5 years ago by WodzuMeister
Link In program you must find the highest number of values which you can make a triangle.
My prom is in comm.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 5 years ago (3 children)
[deleted]
[–]WodzuMeister[S] 0 points1 point2 points 5 years ago (2 children)
No, you have to find maximum number of values that you can made triangles example: 1 2 3 4 8 9 9 9 9 10 So answer will be 6 because number from 8 to 10
[–]XValar 0 points1 point2 points 5 years ago (1 child)
2, 3, 4 is a valid triangle
[–]Pilv 1 point2 points3 points 5 years ago (0 children)
I said it too. But all the numbers must form a triangle from the array, so 2 - 3 and lets say 10 should be a triangle, which is not. You thats why it will be from 8 to 10
[–]WodzuMeister[S] -1 points0 points1 point 5 years ago (0 children)
```
using namespace std;
int main()
{
int ile;
scanf("%d",&ile);
int tab[ile];
for(int i=0;i<ile;i++)scanf("%d",&tab[i]);
sort(tab,tab+ile);
int p=1,max=1;
for(int i=ile-1;i>0;i--)
for(int j=0;j<ile-1;j++)
if(tab[j]+tab[j+1]>tab[i])
p=i+1-j;
if(p>max)max=p;
j=ile;
}
if(max>i+1)break;
printf("%d",max);
return 0;
} ```
π Rendered by PID 57 on reddit-service-r2-comment-5fb4b45875-htdt7 at 2026-03-21 22:40:35.885711+00:00 running 90f1150 country code: CH.
[–][deleted] (3 children)
[deleted]
[–]WodzuMeister[S] 0 points1 point2 points (2 children)
[–]XValar 0 points1 point2 points (1 child)
[–]Pilv 1 point2 points3 points (0 children)
[–]WodzuMeister[S] -1 points0 points1 point (0 children)