Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Paladrone

Name: Anonymous 2006-12-21 8:33

Optimize this code bitches!

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{

     long a,b,c,d,e,f;
     char exit;

     cout << "Please input a 5 digit paladrone number: ";
     cin >> a;

     b = a/10000;
     cout << b << endl;
     c = (a%10000/1000);
     cout << c << endl;
     d = (a%1000/100);
     cout << d << endl;
     e = (a%100/10);
     cout << e << endl;
     f = a%10;
     cout << f << endl;

     if (b == 0) {cout << "That isn't a 5 digit number";}
     else if (b != c){cout << "The first number doesn't match with the last";}
     else if (f != d) {cout << "The secound number doesn't match with the fourth";}
     else {cout << b << f << e << d << c << " is a paladrone";}     return 0;


}

Name: Anonymous 2006-12-25 4:50

>>17
Just goes to show that simply because something is made out of numerals, doesn't mean that you have to manage it as ints or longs or even bignums for that matter. Strings would do just as well, with a leading zero drop for the integral case.

Jeez, 4chan's /prog/ is like amateur hour all the time.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List