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

Pages: 1-

Why doesn't this work fuck you

Name: Anonymousfuckyou 2012-04-21 6:30

#include <iostream>
#include <math.h>
using namespace std;

int checkSize(int palindrome){
int size = 1;
int multiplier = 10;
    while(true){
        if(palindrome/(1*multiplier) == 0){
        return size;
        }
        multiplier*=10;
        size+=1; 
    }
}



bool palindromeCheck(int intArray[], int palindrome){

int size = checkSize(palindrome);
cout<<"SIZE:"<< size<<endl; 

    for(int i = 0; i < size ; i++){
    intArray[i] = (palindrome/pow(10, i)%10;
    cout<<intArray[i]<<endl; 
    }

 for(int x = 0; intArray[x] > intArray[size-x];){
 
 if(intArray[0 + x] != intArray[size - x])
  return 1;
 
  else{x++;}
  }
 
return 0;

}




int main(){

int palindrome;
int numbersize;
bool isPalindrome = false;

    while(true){
    cerr<<"Enter a number to check\n";
    cin>>palindrome;
   
    int palindromeArray[checkSize(palindrome)];

    if(palindromeCheck(palindromeArray, palindrome)){
    cout<<palindrome<<" is a palindrome!\n";}
    else{
    cout<<palindrome<<" is NOT a palindrome.\n";}
    }

}

HINT HINT FAGGOTS: The error is with the POW function. Fuck you

Name: Anonymous 2012-04-21 6:36

Because you forgot code tags. Fuck you

Name: Anonymous 2012-04-21 6:38

what kind of horrible shit is this? cin, cout? use C.

Name: Anonymousfuckyou 2012-04-21 6:42

>>2

#include <iostream>
#include <math.h>
using namespace std;

int checkSize(int palindrome){
int size = 1;
int multiplier = 10;
    while(true){
        if(palindrome/(1*multiplier) == 0){
        return size;
        }
        multiplier*=10;
        size+=1;
    }
}



bool palindromeCheck(int intArray[], int palindrome){

int size = checkSize(palindrome);
cout<<"SIZE:"<< size<<endl;

    for(int i = 0; i < size ; i++){
    intArray[i] = (palindrome/pow(10, i)%10;
    cout<<intArray[i]<<endl;
    }

 for(int x = 0; intArray[x] > intArray[size-x];){
 
 if(intArray[0 + x] != intArray[size - x])
  return 1;
 
  else{x++;}
  }
 
return 0;

}




int main(){

int palindrome;
int numbersize;
bool isPalindrome = false;

    while(true){
    cerr<<"Enter a number to check\n";
    cin>>palindrome;
  
    int palindromeArray[checkSize(palindrome)];

    if(palindromeCheck(palindromeArray, palindrome)){
    cout<<palindrome<<" is a palindrome!\n";}
    else{
    cout<<palindrome<<" is NOT a palindrome.\n";}
    }


IS THIS EVEN A THING.

>>3
no

Name: Anonymous 2012-04-21 6:55

shitpost

Name: Anonymous 2012-04-21 6:59

#include <iostream>
#include <math.h>
using namespace std;
int checkSize(int palindrome){
int size = 1;
int multiplier = 10;
    while(true){
        if(palindrome/(1*multiplier) == 0){return size;}
        multiplier*=10;
        size+=1;
    }
}
bool palindromeCheck(int intArray[], int palindrome){
    int size = checkSize(palindrome);
    cout<<"SIZE:"<< size<<endl;
    for(int i = 0; i < size ; i++){
        intArray[i] = (palindrome/pow(10, i)%10;  //<-- here is your problem, you're missing a closeing parentheses
        cout<<intArray[i]<<endl;                  //    i don't know where you want it to be, after the pow() or after
    }                                             //    the %10
    for(int x = 0; intArray[x] > intArray[size-x];){
        if(intArray[0 + x] != intArray[size - x]) return 1;
        else{x++;}
    }
    return 0;
}
int main(){
    int palindrome;
    //int numbersize;             //these two declaractions
    //bool isPalindrome = false;  //are redundant

    while(true){               
        cerr<<"Enter a number to check\n";
        cin>>palindrome;
        int palindromeArray[checkSize(palindrome)];  //am i the only one who has an issue with this declaration?
        if(palindromeCheck(palindromeArray, palindrome)){ cout<<palindrome<<" is a palindrome!\n";}
        else{cout<<palindrome<<" is NOT a palindrome.\n";}
    }                         
}

Name: Anonymous 2012-04-21 7:06

oops i forgot to fioc the first two declaractions in the first function definition OOPS

here have the [b][o][/u]slackwa[sub]re[/o][/u][/b] version

#include <iostream>#include <math.h>using namespace std;
int checkSize(int palindrome){int size = 1;int multiplier = 10;
    while(true){if(palindrome/(1*multiplier) == 0){return size;}multiplier*=10;size+=1;}}
bool palindromeCheck(int intArray[], int palindrome){int size = checkSize(palindrome);cout<<"SIZE:"<< size<<endl;
    for(int i = 0; i < size ; i++){intArray[i] = (palindrome/pow(10, i))%10;cout<<intArray[i]<<endl;}                                          
    for(int x = 0; intArray[x] > intArray[size-x];){if(intArray[0 + x] != intArray[size - x]) return 1;else{x++;}}
    return 0;}
int main(){int palindrome;while(true){cerr<<"Enter a number to check\n";cin>>palindrome;
    int palindromeArray[checkSize(palindrome)];
    if(palindromeCheck(palindromeArray, palindrome)){ cout<<palindrome<<" is a palindrome!\n";}
    else{cout<<palindrome<<" is NOT a palindrome.\n";}}}

Name: Anonymous 2012-04-21 7:19

>'1*multiplier
nice skills op

Name: Anonymous 2012-04-21 7:23

int palindromeCheck(int p){
  int a=p, b=0;
  while(a){
    b=b*10+a%10;
    a/=10;   
  }
  return b==p; 
}

I hope you are not a CS student OP.

Name: Anonymousfuckyou 2012-04-21 7:36

>>7
Still the same errors.:

Name: Anonymous 2012-04-21 9:57

Still the same dubs

Name: Anonymous 2012-04-21 11:00

>>11
nice dubz bro

Name: Anonymous 2012-04-21 14:07

Here ya go, op.
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>

#define loop for (;;)   /* lol */

char *fgetline(FILE *); /* Exercise for the reader */

int query(const char *prompt, const char *format, ...) {
    va_list args;
    char *line;
    int result;
   
    printf(prompt);
    fflush(stdout);
    if (line = fgetline(stdin)) {
        va_start(args, format);
        result = vsscanf(line, format, args);
        va_end(args);
        free(line);
        return result; }
    else {
        perror("query");
        abort(); } }

int query_num() {
    int num;

    loop {
        if (query("> ", "%d", &num) == 1)
            return num; } }

int reverse(int num) {
    int sign = num < 0;
    if (sign) num = -num;
    int rev = 0;
    while (num > 0) {
        rev = rev * 10 + num % 10;
        num /= 10; }
    if (sign) rev = -rev;
    return rev; }

int is_palindrome(int num) {
    return num == reverse(num); }

void prelude() {
    puts("Palindrome - Check if a number is palindromic.");
    puts(""); }

void report(int num, int yn) {
    if (yn) {
        puts("Palindromic"); }
    else {
        puts("Not"); } }

void run() {
    int num;
    int yn;
   
    prelude();
    puts("Enter number at the prompt");
    loop {
        num = query_num();
        yn = is_palindrome(num);
        report(num, yn); } }

int main() {
    run();
    return 0; }

Name: Anonymous 2012-04-21 19:29

>>10
I didn't say they weren't there, dumbass.

Name: bampu pantsu 2012-05-29 4:33

bampu pantsu

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