Cengizhan
So, basic algorithm is how many squares in N*N square?
N * N + (N-1) *(N-1) + ... 1 * 1 -> Calculate in C++.
S@IF
S@IF
what is best algo for that
Cengizhan
I guess, for loop is the best algo. Whenever I write, it solves my problems.
S@IF
my mean equation
S@IF
i used
counter += pow(n, n)
Cengizhan
No, there is better way.
S@IF
could u solve it.
Cengizhan
counter = (n * (n+1) * (2n + 1)) / 6
S@IF
with complete code
S@IF
how could u think with that angle
means how u got...
S@IF
i tried so many to solve but i never think with such extend
S@IF
means how u got that algo
Cengizhan
I have a bronze medal from math olympics.
S@IF
i know some about this concept but never get into practical
S@IF
hey u solve with that concept.. or just directy got
S@IF
or understand algo
S@IF
okay.. thank you😊
Anonymous
Anonymous
;-; k
sree nandhan
I am confused ... If size of the board is N then no.of box must he N*N right ? ... Sry if i am being stupid here ...
sree nandhan
Oh. Okay 👍
sree nandhan
Thanks .
S@IF
could u just write the code.. it would help me
S@IF
it's okay... thank you for that all explanation
Anonymous
Guys I have a question... is It ok to call only one parameter of a function? (I'm programming on a textbook)
example:
----------------
procedure container ( value1, value3, value5 as Integer){
}
procedure test{
Int local_container
Int taker = container (value5 => local_container)
}
Anonymous
Anonymous
Or should I create a separated package that would contain value1 to value5 and call it externally?
Anonymous
I'm new to programming. I looked for it, but:
+ I found things about sql Because I didn't knew how look to express my problem. So that why I went to human to help me.
Anyway, thank you
Anonymous
We want to display rectangles ( 4 cm width * 3 cm hieght). The input is the number of the required rectangles.
Display them as the following:
Three rectangles in each row. Each row will be 14 cm because we separate rectangles by 1 cm and so the rows.
It must be solved by a mathematical equation to display the rectangles automatically.
Anonymous
I tried this but it's not good enough for this one:
#include <iostream> using namespace std; int main() { int rect; cin>>rect; int blocks, single, fill; single = rect%3; blocks = rect/3; fill = 14; for (int y=0; y<blocks+single; y++){ if (y==blocks) { fill = (single*4)+(single-1); if (single>1) single--;} for (int i=0; i<3; i++){ for (int j=0; j<fill; j++){ if (j==4||j==9) {cout<<' '; continue;} cout<<'*';} cout<<'\n'; } cout<<'\n'; } }
Patrick
Xcix
I need help in trying to solve this..It's actually in C programming..Can somebody please help me?
Xcix
Nils
Youssef
Youssef
Anonymous
Anonymous
Halo guys
Anonymous
Hello, I want to do a little test
I wrote a little program in c++, it's just a simple number guessing game
I'm trying to follow programming best practices but I don't know if I did it the right way (I mean, it looks fine to me but I have 0 confidence because of my lack of experience)
Can I send the .cpp file here, so you can check it and suggest changes and improvements in my way of witting code?
Anonymous
Ya sure
Anonymous
Here it is 😅
Anonymous
I am a beginner start from zero about programming,can u guys help me please
Its so much thanks for u all
Anonymous
Anonymous
Anonymous
no problem
Anonymous
Its my first time trying programming,i try it from the bookpdf,but always error,may i mistake?
Anonymous
Tekipeps
what book is recommended to learn cpp from beginner to advanced please
Brown
How do I change a numbers precision by input number ?
Ex : If I want n digits after decimal. I want this n to be taken from input, scanf or something. How do I do it ?
Monday Morning
vinícius*
vinícius*
vinícius*
float pi = 3.1415926535897;
int decimals = 2;
printf("%.*f", decimals, pi);
vinícius*
that'd print out 3.14
Monday Morning
Works like a charm.
vinícius*
vinícius*
only 'problem' is the weird usage of list initializers
vinícius*
like in int number{generate_random_int()};
int guess{};
vinícius*
it's definitely not wrong, but usually you'd do something like
vinícius*
int number = generate_random_int();
int guess;
vinícius*
well
Anonymous
Is it a little overkill?
They told me the same thing in another programming group haha
vinícius*
it's not like anyone still cares about C++03 and older, so no problem
Anonymous
oh, well
Brown
Anonymous
I think it doesn't, let me check
vinícius*
test.c: In function ‘main’:
test.c:4:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
float pi{3.1415926535897};
vinícius*
nope
Brown
Anonymous
Holy errors batman (I added some suggested modifications)
Anonymous