Anonymous
Not every "serious" program reads from cin, doesn't it?
Francisco
klimi
no..
Francisco
Oh my god, do you know how old that C++ version is?
Anonymous
/warn screen photo, Turbo C
Anonymous
You just can't even write the program down properly line by line from your paper
Anonymous
Anonymous
Anonymous
And you will find an answer to your question
I_Interface
#rules
Anonymous
#rules
That's not the latest ones
Anonymous
But ok
Anonymous
But ok
First you warned me cuz of turbo!
Can you suggest cpp programming software for Windows 10.
klimi
I_Interface
Anonymous
Nameful
Anonymous
バレンタインがいない柴(食用不可)
Sounds like in c++20 we’lll have better way to handle conversion in between string and calendar finally 😭
Dima
バレンタインがいない柴(食用不可)
バレンタインがいない柴(食用不可)
Dima
Dima
We have own stack for this
Dima
Pretty easy to implement
バレンタインがいない柴(食用不可)
Dima
Take look on Unreal Engine 4 for datetime
Dima
They have good stuff
Dima
バレンタインがいない柴(食用不可)
Well yes... but I’d be more happy to use something that’s readily available...
バレンタインがいない柴(食用不可)
Including some external libraries is not as easy in Java (with maven etc) ... really a pain in ass...
Dima
バレンタインがいない柴(食用不可)
And I’m curious ...
バレンタインがいない柴(食用不可)
I understand that in c++ we have functional stuff (lambda functions)
バレンタインがいない柴(食用不可)
But seems like they’re not as flexible to use as in scale (in which we can call a chain of lambda functions in a line)
バレンタインがいない柴(食用不可)
Or there’s some libraries I can look into?
バレンタインがいない柴(食用不可)
Like in scala we can do map then flatten then filter etc in one line.
バレンタインがいない柴(食用不可)
In c++ it seems unable :(
バレンタインがいない柴(食用不可)
Which doesn’t make it as a strong motivation for me to change in habit of writing my code from being imperative to being functional
Anonymous
Given an array, I have to arrange in such a way that all the odd numbers are arranged in ascending order on one side of the array and the remains, i.e. even numbers are arranged in descending order.... How do I approach this?
Anonymous
For eg... 5 8 1 7 2 6 4 should give the output as 1 5 7 8 6 4 2
Anonymous
Anonymous
Built in function is used here.... Can it be done using quicksort?
Francisco
Anonymous
Ohhkkk.... So it can't be done efficiency?
Fabio
I think it's better to use mergesort with some mods, and time will be theta(nlogn)
Surge.rs
Wow someone doesnt like python :P
Anonymous
am sorry
klimi
am sorry
It didn't even make sense
︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎
Anonymous
Harish
What is the problem with this code
Harish
Std:: string
Anonymous
I am asking your arguments are (string s ) if s is array the accept it as string s[]
rex
use ' ' instead of " "
Anonymous
Anonymous
If you use string use " " o and for char ' '
Harish
Okay thank you
Harish
Anonymous
Given a string s consists of upper/lower-case alphabets and empty space characters ' ',. Return the length of last word in the string. If the last word does not exist, return 0.
#include<bits/stdc++.h>
using namespace std;
int last_word(string str)
{
int len=str.length();
int count=0,count_space=0;
for(int i=0;i<len;i++)
{
if(str[len-1-i]!=' ')
count++;
else
{
count_space++;
break;
}
}
if(count_space!=0)
return count;
else
return -1;
}
int main()
{
string str;
cout<<"Enter the string : ";
getline(cin,str);
cout<<last_word(str);
return 0;
}
Anonymous
Some of my test cases are not passing.... Can anyone help me out?
Francisco
Francisco
Just stop counting once you hit a space or the reverse end of the string
Anonymous
Let me try
Francisco
And why are you returning -1?
Anonymous
Sorry it should be return 0, I just returned -1 to get better idea
Francisco
If you think for a moment, you don't need that last condition
Anonymous
I removed the count_space and the last condition
Francisco
Also, don't use that header and avoid using namespace std;
Anonymous
@fgallego96 Thank you for helping me out with the previous question... Can you help me with one more.... Here's the quetion
Given a string A. The only operation allowed is to insert characters at the beginning of the string. Find how many minimum characters are needed to be inserted to make the string a palindrome string. (be case sensitive in this problem) Constraints: 1 ≤ S ≤ 40