Page 1 of 2 [ 28 posts ]  Go to page 1, 2  Next

ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

26 Mar 2007, 6:16 pm

Code:
#include <iostream>
#include <string>
#include <windows.h>

using std::cin;
using std::cout;
using std::endl;

int OnConv(char note)
{
   switch(note)
   {
   case 'c':
      return 262;
   case 'd':
      return 294;
   case 'e':
      return 330;
   case 'f':
      return 349;
   case 'g':
      return 392;
   case 'a':
      return 440;
   case 'b':
      return 494;
   default:
      return 32767;
   }
}

void OnPlay(char *notes, int length)
{
   int i = 0;
   while(notes[i]!=0)
   {
      Beep(OnConv(notes[i]), length);
      i++;
   }
}
int main()
{
   //Code for Twinkle Twinkly Little Star
   /*char a[50] = "c c g g a a g  f f e e d d c  ";
   char b[50] = "f f e e d d c  ";
   OnPlay(a, 100);
   OnPlay(b, 100);
   OnPlay(b, 100);
   OnPlay(a, 100);
   */
   while(1){
      char sMusic[500];
      cout << "Enter notes (c d e f g a b), using spaces to pause: ";
      cin.getline(sMusic, 500);
      OnPlay(sMusic, 100);
      cout << "Play again? (y/n): ";
      cin >> sMusic;
      if(sMusic[0] != 'y')
         break;
      cin.get();
   }
}



hale_bopp
Veteran
Veteran

User avatar

Joined: 2 Nov 2004
Gender: Female
Posts: 17,054
Location: None

26 Mar 2007, 8:10 pm

#include insult

{
cout << "ahayes stinks" << something
}

//I pretty much forgot how to program. It's been 3 years. Also i'm kidding. I can't rember if i've got the <<'s the right way either.



calandale
Veteran
Veteran

User avatar

Joined: 9 Mar 2007
Gender: Male
Posts: 12,439

26 Mar 2007, 8:14 pm

@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


Not mine, but it's a classic. Note that @P is necessary.



Last edited by calandale on 26 Mar 2007, 9:25 pm, edited 1 time in total.

SweXtal
Deinonychus
Deinonychus

User avatar

Joined: 11 Nov 2006
Age: 54
Gender: Male
Posts: 304
Location: Mora, Sweden

26 Mar 2007, 8:53 pm

move.l #0,$4.w

You wrote it should be short... writes over the Amiga computer zeropage single pointer to everything to NIL and the computer locks up. Graceful keyboard reset or powercycle is your way out.... nothing more is needed since the $4 adress contains in RAM mirror the only absolute adress in memory for the exec.



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 75
Gender: Male
Posts: 9,795
Location: Somerset UK

26 Mar 2007, 8:58 pm

Code:
g++     twinkle.cc   -o twinkle
twinkle.cc:3:21: error: windows.h: No such file or directory
twinkle.cc: In function ‘void OnPlay(char*, int)’:
twinkle.cc:37: error: ‘Beep’ was not declared in this scope
make: *** [twinkle] Error 1


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

26 Mar 2007, 9:37 pm

Lau wrote:
Code:
g++     twinkle.cc   -o twinkle
twinkle.cc:3:21: error: windows.h: No such file or directory
twinkle.cc: In function ‘void OnPlay(char*, int)’:
twinkle.cc:37: error: ‘Beep’ was not declared in this scope
make: *** [twinkle] Error 1


I don't know how to access the PC speaker through the Linux API.

It took me forever to find a way to do it in Windows.



paranoid_android
Toucan
Toucan

User avatar

Joined: 1 Feb 2007
Gender: Male
Posts: 263

26 Mar 2007, 10:44 pm

Code:
double n=1;
double sum=0;
while(sum<10)
{sum=sum+1/n;
n++;}
n--;
return n;

Java program to find how high you have to go to get the harmonic series to reach 10.



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 75
Gender: Male
Posts: 9,795
Location: Somerset UK

26 Mar 2007, 11:05 pm

Code:
char *q="abcdefdbcgfahcijgklmnhcgmocdijlndcdijlndahclndcpgmhcgmocqjrpl\
ncqjrplnabcpkgcgmhcgmocqmgcmqcqmgcmqascgmhtgmocqmgcmrcqmgcmrascgmhkgme\
cdefdecqmcijgcqmcijucdvfdascgmhcgmgcwmkckmwgcqmijecqmijucijkgcklmefasc\
gmhcgmgcqmdcdmqgcqmjucqmjucwmrucdmqascgmhclmdcplntijrcdimndxcdimndxcdi\
mdecdimrascgmhcplumjklumjrklemjrklgmjklumjkeagcdefdycgfycdgfacijgklmtv\
cgmvcdmjzcdijlnd{cmqaclndcpgmvcgmvcimrzcqjrpln{cmqagcpkgcgmvcgmvcgm|cq\
mgcmq{cmqaycgmvcgmvcgm|cqmgcmr{cmqaycgmvcgmvcgmucdvfdvcdyfdgcqmcijucdu\
fdmqaycgmvcgmvcgmecijkgcklmefgcijukmqgcqmijucijkgcklmqayclmucdgmducmjg\
cwmrucdmqecdmrucmqgcqmjucwmrucdmqahclngdimgkmngdijgcdimdecdimrgcdijvcl\
mgdimndxcdimdecdimndabckgmkuckgmkecjklumjkucmjycplgmjrklgmjklumjkplma";
int r[]={10,-8,32,44,-3,103,-2,-7,100,80,34,89,56,98,-11,96,73,39,
-12,97,-4,-5,105,95,-6,-25,-9,-26};
int main(int argc, char *argv[]){int c,n = 1;while((c = *q++))
if((c=r[c-97])<0)n=-c;else{do putchar(c);while(--n);n=1;}return 0;}


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


TheBladeRoden
Veteran
Veteran

User avatar

Joined: 10 Feb 2005
Age: 40
Gender: Male
Posts: 1,208
Location: Wisconsin

26 Mar 2007, 11:10 pm

Code:
main() {
       printf("hello, world");
}


_________________
"I reject your reality, and substitute my own" -Adam Savage


calandale
Veteran
Veteran

User avatar

Joined: 9 Mar 2007
Gender: Male
Posts: 12,439

26 Mar 2007, 11:40 pm

a .is '''a .is '',a[1 1],(8 .take a),(7 .drop a),a[1], .bxtclf,a'
'a .is ',a[1 1],(8 .take a),(7 .drop a),a[1], .bxtclf,a



ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

27 Mar 2007, 12:55 am

Lau wrote:
Code:
char *q="abcdefdbcgfahcijgklmnhcgmocdijlndcdijlndahclndcpgmhcgmocqjrpl\
ncqjrplnabcpkgcgmhcgmocqmgcmqcqmgcmqascgmhtgmocqmgcmrcqmgcmrascgmhkgme\
cdefdecqmcijgcqmcijucdvfdascgmhcgmgcwmkckmwgcqmijecqmijucijkgcklmefasc\
gmhcgmgcqmdcdmqgcqmjucqmjucwmrucdmqascgmhclmdcplntijrcdimndxcdimndxcdi\
mdecdimrascgmhcplumjklumjrklemjrklgmjklumjkeagcdefdycgfycdgfacijgklmtv\
cgmvcdmjzcdijlnd{cmqaclndcpgmvcgmvcimrzcqjrpln{cmqagcpkgcgmvcgmvcgm|cq\
mgcmq{cmqaycgmvcgmvcgm|cqmgcmr{cmqaycgmvcgmvcgmucdvfdvcdyfdgcqmcijucdu\
fdmqaycgmvcgmvcgmecijkgcklmefgcijukmqgcqmijucijkgcklmqayclmucdgmducmjg\
cwmrucdmqecdmrucmqgcqmjucwmrucdmqahclngdimgkmngdijgcdimdecdimrgcdijvcl\
mgdimndxcdimdecdimndabckgmkuckgmkecjklumjkucmjycplgmjrklgmjklumjkplma";
int r[]={10,-8,32,44,-3,103,-2,-7,100,80,34,89,56,98,-11,96,73,39,
-12,97,-4,-5,105,95,-6,-25,-9,-26};
int main(int argc, char *argv[]){int c,n = 1;while((c = *q++))
if((c=r[c-97])<0)n=-c;else{do putchar(c);while(--n);n=1;}return 0;}


Code:
        ,ggg,        gg
       dP""Y8b       88           ,dPYb, ,dPYb,
       Yb, `88       88           IP'`Yb IP'`Yb
        `"  88       88           I8  8I I8  8I
            88aaaaaaa88           I8  8' I8  8'
            88"""""""88   ,ggg,   I8 dP  I8 dP    ,ggggg,
            88       88  i8" "8i  I8dP   I8dP    dP"  "Y8ggg
            88       88  I8, ,8I  I8P    I8P    i8'    ,8I
            88       Y8, `YbadP' ,d8b,_ ,d8b,_ ,d8,   ,d8'
            88       `Y8888P"Y8888P'"Y888P'"Y88P"Y8888P"


  ,ggg,      gg      ,gg
 dP""Y8a     88     ,8P                         ,dPYb,         8I
 Yb, `88     88     d8'                         IP'`Yb         8I
  `"  88     88     88                          I8  8I         8I
      88     88     88                          I8  8'         8I
      88     88     88    ,ggggg,     ,gggggg,  I8 dP    ,gggg,8I
      88     88     88   dP"  "Y8ggg  dP""""8I  I8dP    dP"  "Y8I
      Y8    ,88,    8P  i8'    ,8I   ,8'    8I  I8P    i8'    ,8I
       Yb,,d8""8b,,dP  ,d8,   ,d8'  ,dP     Y8,,d8b,_ ,d8,   ,d8b,
        "88"    "88"   P"Y8888P"    8P      `Y88P'"Y88P"Y8888P"`Y8


showoff



hacker_mage
Blue Jay
Blue Jay

User avatar

Joined: 15 Jan 2006
Gender: Male
Posts: 78

27 Mar 2007, 3:17 pm

cls
PRINT "CHOCOLATE MILK"



larsenjw92286
Veteran
Veteran

User avatar

Joined: 30 Aug 2004
Age: 38
Gender: Male
Posts: 8,062
Location: Seattle, Washington

27 Mar 2007, 5:18 pm

If there was such a thing as a random money-generating program in which you could tell it to give you any amount you wanted and it put that amount of money right in your hard drive, I would be very happy!


_________________
Jason Larsen
[email protected]


lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 75
Gender: Male
Posts: 9,795
Location: Somerset UK

28 Mar 2007, 1:40 am

Code:
100INPUT"How much money would you like?"!a$
200OPEN_NEW#3;"win1_money"
300PRINT#3;a$
400CLOSE#3
500PRINT"Money stored"


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


Gilb
Veteran
Veteran

User avatar

Joined: 4 Jan 2007
Gender: Male
Posts: 1,214

28 Mar 2007, 2:05 am

using system.windows.console;

Main()
{
console.writeline("Hello all you C# programmers out there");
console.writeline("oh that is no one lol");
console.readline();
}



ahayes
Veteran
Veteran

User avatar

Joined: 2 Dec 2006
Gender: Male
Posts: 9,506

28 Mar 2007, 2:13 am

#include <iostream>
#include <fstream>
using namespace std;

void main()
{
ofstream outfile("munybuks.txt");
double munybuks;
cout << "How much money?";
cin >> munybuks;
outfile << "You now have $" << munybuks << ".";
outfile.close();
}