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

Pages: 1-

Help with programming

Name: Anonymous 2011-03-28 23:05

    #include <iostream>
    #include <stdlib.h>
    #include <cstdlib>
    #include <cmath>
    
    char isvowel(char);
    using namespace std;
    
    int vowelCount;
    
    int main()
    {
        char input[200];
            for(int i = 0; i < 200; i++){
                    input[i] = '\0';
            }
          
            printf("\n\nInput a sequence of characters (200 maximum)...");
            cin.getline(input, 200);
          
            printf("\nYou input '%s'\n", input);
          
            cout << isvowel(input) << endl;;
          
        printf("\nVowels found: %u", vowelCount);
        system("Pause");
        return 0;
    }
    
    char isvowel(char j)
    {
         int j;
         char v[12]={'A','a','E','e','I','i','O','o','U','u','y','Y'};
         for(int j = 0; j < 12; j++){
                                            if(input[i] == vowels[j]){
                                                    printf(" matches found.");
                                                    vowelCount++;
                                                    break;
                        }
                                                  
                                    return isvowel;
    }


Thank you guys in advance --- I need to input a sequence and give out the number of vowels used in that sequence. All help is appreciated.

Name: Anonymous 2011-03-28 23:07

    #include <iostream>
    #include <stdlib.h>
    #include <cstdlib>
    #include <cmath>
   
    char isvowel(char);
    using namespace std;
   
    int vowelCount;
   
    int main()
    {
        char input[200];
            for(int i = 0; i < 200; i++){
                    input[i] = '\0';
            }
         
            printf("\n\nInput a sequence of characters (200 maximum)...");
            cin.getline(input, 200);
         
            printf("\nYou input '%s'\n", input);
         
            cout << isvowel(input) << endl;;
         
        printf("\nVowels found: %u", vowelCount);
        system("Pause");
        return 0;
    }
   
    char isvowel(char j)
    {
         int j;
         char v[12]={'A','a','E','e','I','i','O','o','U','u','y','Y'};
         for(int j = 0; j < 12; j++){
                                            if(input[i] == vowels[j]){
                                                    printf(" matches found.");
                                                    vowelCount++;
                                                    break;
                        }
                                                 
                                    return isvowel;
    }

Name: Anonymous 2011-03-28 23:09

that code doesnt compile - We're you just repasting?

Name: Anonymous 2011-03-28 23:14

Why aren't you using any of C++'s object oriented features?

You might as well fucking be using C

I fucking hate people like you.

Name: Anonymous 2011-03-28 23:16

I want to use the object oriented stuff - but my assignment says it has to specifically be a  user oriented function. Which is asinine I know...

Name: Anonymous 2011-03-28 23:21


Please don't think what you're learning has anything to do with ``user-oriented'' or even ``object-oriented''.
Instead, learn how to do this with a basic FORCED ONE-LINER first.

Name: Anonymous 2011-03-28 23:21

Anyways, the program you're using can't even handle a string over 200 characters long? What Gives?

Name: Anonymous 2011-03-28 23:25

It doesn't compile for me. How do you know it cant take 200 characters?

Name: Anonymous 2011-03-28 23:29

Name: Anonymous 2011-03-28 23:29

Name: Anonymous 2011-03-28 23:34

>>9
>>10

What exactly do these do?

Name: Anonymous 2011-03-28 23:37

Please read http://www.nambla.org

Name: Anonymous 2011-03-28 23:40

Sorry it took so long, here's your code, fixed and all.
while read p; do echo $p| sed -e 's/[!aeiouy]//gI'; done

Name: Anonymous 2011-03-28 23:43

#include <stdio.h>

int main(){
  int k = 0x1104111;
  char s[200]="\0", *c=s; 
 
  fgets(s+1,200,stdin);
  while(*++c)
   *s+=(k>>(*c-((*c>96)<<5)-65))&1;
  printf("%d", *s);

  return 0;
}

Name: Anonymous 2011-03-28 23:51

>>13
>>14

Wow thank you guys for the help but I have no idea how to use this code :( - Similarly I have to make this a user defined function. Thanks for your help though I guess im hopeless with this part...

Name: Anonymous 2011-03-28 23:53

>>12

Please read www.stormfront.org

Name: Anonymous 2011-03-28 23:53

second one is c code, you compile and run it. duh.

Name: Anonymous 2011-03-28 23:54

>>14

Ok I input this code and it works great thanks! But I just need to separate it so it parses from one input to a external function :|.

Name: Anonymous 2011-03-28 23:55

#include <stdio.h>
#define isvowel(c)((c)=='a'||(c)=='e'||(c)=='i'||(c)=='o'||(c)=='u')
int main(){int c,n=0;l:c=getchar();if(c!=EOF&&c!='\n'){if(isvowel(c|0x20))n++;goto l;}printf("%d\n",n);}

Name: Anonymous 2011-03-29 0:00

>>18

#include <stdio.h>

#define magic 0x1104111

int isvowel(char *s){
  char *c=s-1,k=0;
  while(*++c)
   k+=(magic>>(*c-((*c>96)<<5)-65))&1;
  return k;
}

int main(){
  char s[200]; 
  printf("%d", isvowel(fgets(s,200,stdin)));
  return 0;
}

Name: Anonymous 2011-03-29 0:01

>>19
>goto
BAD PRACTICE

Name: Anonymous 2011-03-29 0:06

>>20

Thank you so much :D

Name: Anonymous 2011-03-29 0:22

>>22
if you actually turn this in then you will be fucked...
it's obvious that you didn't do it yourself

Name: Anonymous 2011-03-29 0:35

>>1,23
That's not entirely true, they just need to turn in the references. Not like most /prog/ professors know of this board or anything.

Name: Anonymous 2011-03-29 0:38

>>24
if he turns in an obfuscated program the professor will realize something is up

Name: Anonymous 2011-03-29 0:40

>>25
obfuscated? the code is as simple as possible. My only concern is other students can write similar codes. you have to add some comments OP

Name: Anonymous 2011-03-29 0:44

>>26
I guess he is a php programmer. Even a hello world program would be too complicated for him.

Name: Anonymous 2011-03-29 0:50

What the fuck do you want us to do? You didn't say if there are any errors. Also, by sequence do you mean string/array?

Name: Anonymous 2011-03-29 2:01

#define VOWELFLAG (1 << ('a' - 'a') | \
                   1 << ('e' - 'a') | \
                   1 << ('i' - 'a') | \
                   1 << ('o' - 'a') | \
                   1 << ('u' - 'a') | \
                   1 << ('y' - 'a'))

#define ISVOWEL(c) (isalpha(c) && (VOWELFLAG & (1 << (tolower(c) - 'a'))))

Name: Anonymous 2011-03-29 2:44

bool isVowel(char letter,bool isLast = false)
{
  switch (letter)
  {
  case 'A':
  case 'E':
  case 'I':
  case 'O':
  case 'U':
    return true;
  case 'Y':
    return isLast;
  default:
    return false;
  }
}

Name: Anonymous 2011-03-29 2:45

>>29

How do you use that font? I fucked up >>30

Name: Anonymous 2011-03-29 3:22

>>20
I have never seen anything this beautiful.
Before I go back to /b/ I must ask:
Are you a wizard?

Name: Anonymous 2011-03-29 5:51

>>32
Before I go back to /b/
Why in the world would you subject yourself to being in that hellhole?

Name: Anonymous 2011-03-29 6:30

<--- check my dubs

Name: Anonymous 2011-03-29 6:30

>>31
[code][/code]

Name: Anonymous 2011-03-29 10:20

>>34
>>35
Double fail!

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