many
After endless repetitive orm pattern, I finally realized why people write in lisp
many
I should have known the existence of lisp earlier
Anonymous
Explain it
klimi
I've never written 2 cpp files in a single g++ command.
o.o , like ... if you program is bigger than one cpp
Anonymous
o.o , like ... if you program is bigger than one cpp
You mean it's like building the entire project?
olli
You mean it's like building the entire project?
it compiles and links multiple files. Although I would recommend against it for bigger projects
Aniket
Hello
Aniket
I'm new
klimi
Hello!
Anonymous
Gn
Anonymous
😴😴
Anonymous
Shwe
Hi
Shubham
Hii
Anonymous
Hi
kr4T0X
kr4T0X
Check this... I'm having kind of logical error or is there something else?
Anonymous
And the code should be pasted via paste services, no files
Mohd
Is 9.36-12 a valid real constant??? in C language
Anonymous
And what do you mean by "valid real constant"?
Anonymous
How to use paste service?😟😥
Well... I can't find anything difficult in using paste services
kr4T0X
Wait
kr4T0X
#include<stdio.h> #include<conio.h> main() { clrscr(); char F, S, T, Fo; printf(" Hello :) \n"); printf("Q1 \n"); scanf("%c", &F); if(F=='y') { printf("R1 \n"); printf("Q2 \n"); scanf("%c", &S); if(S=='y') { printf("R2 \n"); printf("Q3 \n"); scanf("%c", &T); if(T=='y') { printf("R3 \n"); printf("Q4 \n"); scanf("%c", &Fo); if(Fo=='y') printf("R4 \n"); else { if(Fo=='n') printf("R44 \n"); else printf("A4 \n"); } } else { if(T=='n') printf("R33 \n"); else printf("A3 \n"); } } else { if(S=='n') printf("R22 \n"); else printf("A2 \n"); } } else { if(F=='n') printf("R11 \n"); else printf("A1 \n"); } getch(); return 0; }
kr4T0X
Like this?
Dima
WHAT
Dima
who the hell teaches you to name variables like that!
kr4T0X
It's just an hierarchy, not the real code.😑
Anonymous
Like this?
Can read the rules?!
kr4T0X
Can read the rules?!
Let me check them again..😬😬
kr4T0X
Sorry, for bad english. Let me check the rules.
kr4T0X
Again!
Dima
It’s not about the English, just don’t post your raw large code snippets like that, use pastebin/hastebin etc..
kr4T0X
Oh, okay! I'm sorry.🙁
Anonymous
Oh, okay! I'm sorry.🙁
And make the variables name GOOD
kr4T0X
I'll.
Anonymous
for(int i=0;i<a.length()-2;++i){ ans = max(ans,r[i+1] - l[i]-1); }
Anonymous
Here, a is a string
Anonymous
the length of a is 1
Anonymous
But during debugging, I found that the loop was getting executed twice or thrice
Anonymous
The I did this: int x = a.length(); for(int i=0;i<x-2;++i){ ans = max(ans,r[i+1] - l[i]-1); }
Anonymous
And suddenly it worked well
Anonymous
The loop didn't execute at all which should have happened.
Anonymous
Is writing for(int i=0;i<a.length()-2;++i) BAD in c++ ?
Anonymous
Anonymous
in modern C++ it is especially bad
You mean looping with condition a.length() ?
Anonymous
Modern means C++11 ot newer
Anonymous
Yes, I mean it too
too? What else is wrong?
Anonymous
And this one is bad also
So, what is the right way?
Anonymous
The right way in modern C++ is using range-based for
Anonymous
auto
Kindly elaborate.
I_Interface
Ye, as Danya said: range based loops and auto for vars, that's is modern cpp
Anonymous
for example: std::string str = "..."; for (auto ch : str} f(ch)
I_Interface
auto& is better :3
Anonymous
Anonymous
It depends
Well you don't want to make copy everytime. but, yes it depends
I_Interface
or const auto& if u won't change it
Anonymous
Well you don't want to make copy everytime. but, yes it depends
As I said — it depends If you have a collection of fundamental types as the std::string is, it is better not to use references or const references
Anonymous
The right way in modern C++ is using range-based for
Before that you didn't tell me why what I did is a bad practice?
Anonymous
Before that you didn't tell me why what I did is a bad practice?
looping through a collection using indexes if you don't need them
I_Interface
Before that you didn't tell me why what I did is a bad practice?
No, u did just an old C-style :) raw loop is good for an array for collections range-based loop is much better
I_Interface
And yes, not all collections have index operator
Anonymous
No, u did just an old C-style :) raw loop is good for an array for collections range-based loop is much better
Sounds like It is thing of doing it in a better way. But, I guess what I did was good too and shouldn't be erroneous.
Anonymous
Isn't it?
Anonymous
It's only you thinking so