Help with programming
1
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.
2
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;
}
3
Name:
Anonymous
2011-03-28 23:09
that code doesnt compile - We're you just repasting?
4
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.
5
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...
6
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.
7
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?
8
Name:
Anonymous
2011-03-28 23:25
It doesn't compile for me. How do you know it cant take 200 characters?
9
Name:
Anonymous
2011-03-28 23:29
10
Name:
Anonymous
2011-03-28 23:29
11
Name:
Anonymous
2011-03-28 23:34
>>9
>>10
What exactly do these do?
12
Name:
Anonymous
2011-03-28 23:37
13
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
14
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;
}
15
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...
16
Name:
Anonymous
2011-03-28 23:53
17
Name:
Anonymous
2011-03-28 23:53
second one is c code, you compile and run it. duh.
18
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 :|.
19
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);}
20
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;
}
21
Name:
Anonymous
2011-03-29 0:01
22
Name:
Anonymous
2011-03-29 0:06
>>20
Thank you so much :D
23
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
24
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.
25
Name:
Anonymous
2011-03-29 0:38
>>24
if he turns in an obfuscated program the professor will realize something is up
26
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
27
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.
28
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?
29
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'))))
30
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;
}
}
31
Name:
Anonymous
2011-03-29 2:45
>>29
How do you use that font? I fucked up
>>30
32
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?
33
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?
34
Name:
Anonymous
2011-03-29 6:30
<--- check my dubs
35
Name:
Anonymous
2011-03-29 6:30
36
Name:
Anonymous
2011-03-29 10:20