[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Are you enough smart? #include<iostream> #include<cstring>

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 24
Thread images: 4

File: cpp-array.png (5KB, 514x195px) Image search: [Google]
cpp-array.png
5KB, 514x195px
Are you enough smart?

#include<iostream>
#include<cstring>
#include<string.h>
using namespace std;

int main()
{
char phrase[100];
start:
cout << "Insert phrase:" << endl;
cin.getline(phrase,100, '\n');
int x=strlen(phrase);

char phrase2[x];
int j=0;
for (int n=0; n<=x; n++) {
if (phrase[n]!=' ') {phrase2[j]=phrase[n]; j++;}
}

char reverse[x];
j=j-2;
for (int n=0; n<=x; n++) {
reverse[n]=phrase2[j];
j--;}

if (strcmp(reverse,phrase2)==0)
cout << "Palindromic";
else
cout << "Not palindromic";
cout << endl;
cout << reverse; //WHY REVERS ARRAY IS FUCKED UP?!
return 0;
}


INPUT:
amica di pirati vede ed evita ripida cima
>>
#include <algorithm>
#include <string>
#include <iostream>
#include <cctype>

int main() {
std::string phrase;
std::cout << "Enter pharase: ";
std::getline(std::cin, phrase);
std::cout << "" << std::endl;

phrase.erase(std::remove_if(phrase.begin(), phrase.end(), ::isspace),phrase.end());

std::string phrase2 = phrase;

std::reverse(phrase2.begin(), phrase2.end());

if (phrase == phrase2) {
std::cout << "PALINDROME" << std::endl;
} else {
std::cout << "NOT A PALINDROME" << std::endl;
}

return 0;
}

You're a fucking retard OP.
>>
>buffer overflow
back to java pajeet
>>
input="im gay and also gay y a g osla dna yag mi"
print("PALINDROME" if input.replace(" ","")==input.replace(" ","")[::-1] else "NOT PALINDROME"
>>
>>59562521
>char phrase2[x];
x isn't a constant expression dumbass
>>
>>59563308
)
>>
>>59562521
>C++
>uses C strings anyways
>buffer overflows everywhere
kys, OP.
>>
>>59563308
Python's syntax to reverse lists is pretty retarded
>>
>>59562521
Thank you for a decent post that isn't shilling, senpai
>>
>>59563340
because using reverse slicing like that is actually pretty retarded
list(reversed(input)) will work much better
>>
>>59563340
python's everything is fucking retarded

polluted global namespace with retarded functions like len() when the language is OO, statements for literally everything under the sun, no real lambdas.

why anyone uses it is beyond me.
>>
>>59563226
>creating a copy

#include <algorithm>
#include <string>
#include <iostream>
#include <cctype>

int main()
{
std::string p;

std::cout << "Enter phrase: ";
std::getline(std::cin, p);
std::cout << std::endl;

phrase.erase(std::remove_if(p.begin(), p.end(), ::isspace), p.end());

if(std::equal(p(), p.end() + p.size()/2, p.rbegin()))
{
std::cout << "PALINDROME" << std::endl;
}
else
{
std::cout << "NOT A PALINDROME" << std::endl;
}

return 0;
}
>>
>>59562521
>no code box
didn't read
>>
>>59563452
>p.begin()
FTFM
>>
File: Screenshot_2017-03-24_17-09-08.png (15KB, 1027x183px) Image search: [Google]
Screenshot_2017-03-24_17-09-08.png
15KB, 1027x183px
>>59562521
Surely you can, /g/?
>>
>>59563572
largest possible sum: 999 + 999 = 1998
so the largest possible is obviously: 1991
>>
>>59563627
Oh sorry, it says product not sum.
Can't do that in my head anymore.
>>
>>59563572
Apparently I can
>>
>>59563676
So can I, give me a minute.
>having an account
Why?
>>
>>59563340
ya use django1.5 way better for python
>>
>>59563572
>>59563676
# Generate all palindromic products of two 3-digit numbers. 
for i in range(10001, 1000000):
if str(i) == str(i)[::-1]:
for m in range(100, 1000)[::-1]:
if i % m == 0 and 100 <= i / m <= 999:
print(i, '=', int(i / m), 'x', m)
break

906609
>>
>>59563804
>>having an account
>Why?
So that now, three years after solving it, I can go back to see if I solved it.
>>
File: 1489531799363.jpg (45KB, 341x500px) Image search: [Google]
1489531799363.jpg
45KB, 341x500px
>>59564055
>he doesn't have redundant backups of every piece of code minor or not he's ever written
>>
>>59562521
>string.h
>using namespace std;
>char phrase2[x]
>char reverse[x]
REEEEEEEEEEE
Thread posts: 24
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.