Sutekh's C++ +More Thread

  • Guest, it's time once again for the hotly contested and exciting FoH Asshat Tournament!



    Go here and fill out your bracket!
    Who's been the biggest Asshat in the last year? Once again, only you can decide!

sole

Molten Core Raider
338
1,203
Thanks for the .zip, working great. As far as corner cases, ultimately I'd like to have control over them during transcription. Using your example, "Farewell cruel world..." I would like to have a tag marker for the automated count, e.g., "Farewell cruel world...[sentence]" where I deliberately manipulate the transcription to get a more accurate automated response. Ideally, [sentence] would just be a character not found in written world languages, like, "d??" ... "Farewell cruel world...d??". In this case the program would know to associate that symbol with a sentence break. Words are a lot trickier... do you count all characters? do you omit spaces? what if there are ~8 spaces in a row... (this is where the project would become very involved). I have to note every minute detail in this regard, but I'm extremely curious if a simple word/sentence counting/averaging program would aid in judging initial veracity.

For now I think words separated by a space, and a "d??" to separate sentences would be a great way to test out what, if any, correlations there are between automated and manual counting.

Thanks again Tuco, can't wait to test it out.
 

Nemesis

Bridgeburner
1,191
628
*in his best Keanu voice*

I know coding

rrr_img_59981.jpg
 

Tuco

I got Tuco'd!
<Gold Donor>
45,320
73,377
Thanks for the .zip, working great. As far as corner cases, ultimately I'd like to have control over them during transcription. Using your example, "Farewell cruel world..." I would like to have a tag marker for the automated count, e.g., "Farewell cruel world...[sentence]" where I deliberately manipulate the transcription to get a more accurate automated response. Ideally, [sentence] would just be a character not found in written world languages, like, "d??" ... "Farewell cruel world...d??". In this case the program would know to associate that symbol with a sentence break. Words are a lot trickier... do you count all characters? do you omit spaces? what if there are ~8 spaces in a row... (this is where the project would become very involved). I have to note every minute detail in this regard, but I'm extremely curious if a simple word/sentence counting/averaging program would aid in judging initial veracity.

For now I think words separated by a space, and a "d??" to separate sentences would be a great way to test out what, if any, correlations there are between automated and manual counting.

Thanks again Tuco, can't wait to test it out.
But if you do that you're just inventing a new programming language instead of learning the existing one you're using! It may be worth your time trying to solve those corner cases with C# instead of Sole#, but it's up to you.
 

James

Ahn'Qiraj Raider
2,804
7,056
Swap the value of these two variables without using a third variable

int main()
{

int a = 42;
int b = 7;

return 0;
}

void main() {
int a = 42;
int b = 7;
a += b;
b = a-b;
a -= b;
}
 
  • 2Like
Reactions: 1 users

Kharzette

Watcher of Overs
4,856
3,472
Code:
void main(void)
{
    int    a    =42;
    int    b    =7;

    a    =b ^ a;
    b    =a ^ b;
    a    =b ^ a;
}

Since this is in screenshots:

04ac7b163234850c3d47b8d866b4b350.jpg
ffc49b7379b84142e0ebf6538d9f55f6.jpg
30e4659b5e9ad49a88e939234210bfae.jpg
 
Last edited:

James

Ahn'Qiraj Raider
2,804
7,056
What's the reasoning behind void main(void)? Just readability?
 
  • 1Like
Reactions: 1 user

Kharzette

Watcher of Overs
4,856
3,472
I dunno! I guess I did that from habit. I think maybe back in the elder days if you left it blank it did something funny like assumed an int argument or something?
 

Heriotze

<Gold Donor>
1,031
1,410
lowbrow js way to accomplish although I don't see array and scope setup being much different in other languages:
let a = 42;
let b = 7;
b = [a, a = b][0];
 

spronk

FPS noob
22,478
25,383
void main() {
int a = 42;
int b = 7;
a += b;
b = a-b;
a -= b;
}

int main() can be called with any number of arguments, int main(void) can only be called with zero arguments. main is supposed to return 0 if it ran with no error and an error code otherwise so void main() is technically not right but it'll run of course.


#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {

int a=0,b=1;
string strTemp;



cout << "enter integer a: ";
getline (cin,strTemp);
stringstream(strTemp) >> a;

cout << "enter integer b: ";
getline (cin,strTemp);
stringstream(strTemp) >> b;



cout << "a is " << a << " b is " << b << endl;

a = a ^ b;
b = a ^ b;
a = a ^ b;

cout << "after swap a is now " << a << " b is " << b << endl;
return 0;
}

uses XOR bit shifting to swap numbers, i believe there is a case where it fails when you have a very high number since you run out of bits to shift into but i don't honestly remember

online C++ compiler for testing fun
C++ Shell
 
Last edited:

Nirgon

YOU HAVE NO POWER HERE
12,581
19,318
Is this another "do my homework thread"?

If you don't strongly desire doing this kind of thing and figuring out answers on your own, run as far away as u can from this field of study. The textbooks/exams questions are one thing, helping clueless_PM_005 steering you wrong out of the gate is a whole nother beast.
 
  • 1Solidarity
Reactions: 1 user