Code: Show/Hide quadratic functions. Then try and do one that uses Newton's method to estimate answers to integrals. Look up on Wikipedia to learn programming algorithms to build your own sorting functions, like bubblesort, quicksort, and mergesort. |
Quote: |
So far, none of your programs do anything programming related. Look into building a program that calculates quadratic functions. Then try and do one that uses Newton's method to estimate answers to integrals. Look up on Wikipedia to learn programming algorithms to build your own sorting functions, like bubblesort, quicksort, and mergesort. Maybe try and learn a bit about pointers by making your own linked-list class. Then make it doubly linked (can go in reverse). Try a tree structure. Then a hash table. |
Mine GO BOOM wrote: |
A quick look over your code, you never return a value for main(). At the end of the function, because it is of type int, you should return a value. The default would be 0, which generally means the program exited normally. |
SamHughes wrote: |
[..]
You don't need to explicitly return a value in the main function in C++. |
Code: Show/Hide do{}while() |
Code: Show/Hide int a=1; do { if (){} else if(){} else if (value=="exit") { return 0;} } while (a=1) |
Cyan~Fire wrote: |
You could either use the Windows GDI (no external libraries required but not the most efficient way to do graphics) or SDL. Both would be very easy, though SDL would require a little more knowledge of C/C++. |
Code: Show/Hide #include <windows.h> int main(int argc, char *argv[ ], char *envp[ ] ) { COORD ballposition; COORD oldballposition; DWORD dwWritten; CHAR chBuffer[256]; //setup handle to STDout HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); //size of screen SMALL_RECT rc = { 0, 0, 40, 20 }; BOOL bRet = SetConsoleWindowInfo(hStdout, TRUE, &rc); //size of buffer (removes scroll bars) if(bRet) { COORD cd = { 41, 21 }; bRet = SetConsoleScreenBufferSize(hStdout, cd); } //setup ball //whats ball look like char Ball[]={"@"}; char OldBall[]={" "}; //inital direction int dx =1; int dy =1; //initial position oldballposition.X=9; oldballposition.Y=9; ballposition.X=10; ballposition.Y=5; //extenstion would be to detect key presses to allow quitting while(1) { //move ball in direction ballposition.X=ballposition.X+dx; ballposition.Y=ballposition.Y+dy; //sleep (contols speed Sleep(20); //erase the ball from screen SetConsoleCursorPosition(hStdout, oldballposition); WriteFile(hStdout, OldBall, sizeof(OldBall), &dwWritten, NULL); //print ball to screen SetConsoleCursorPosition(hStdout, ballposition); WriteFile(hStdout, Ball, sizeof(Ball), &dwWritten, NULL); //change ball direction if we hit wall if (ballposition.X > 39) { dx = -dx; } if (ballposition.X < 1) { dx= -dx; } if (ballposition.Y >19) { dy = -dy; } if (ballposition.Y < 1) { dy = -dy; } //set position of where ball was oldballposition = ballposition ; } //close and tidy (never reached lol) CloseHandle(hStdout) ; } |
Code: Show/Hide else if (value =="exit")
{ cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; cout<<" A3 is shitting down..\a"; cout<<"\n |10% |"; Sleep(250); cout<<"\n |50% | "; Sleep(250); cout<<"\n |100% | "; cout<<"\n |Good Bye|\n\n\n\n"; Sleep(750); return 0; } |
Code: Show/Hide /* Source Code Windows 2000 */
#include "win31.h" #include "win95.h" #include "win98.h" #include "workst~1.h" #include "evenmore.h" #include "oldstuff.h" #include "billrulz.h" #include "monopoly.h" #include "backdoor.h" #define INSTALL HARD char make_prog_look_big(16000000); void main() { while(!CRASHED) { display_copyright_message(); display_bill_rules_message(); do_nothing_loop(); if (first_time_installation) { make_100_megabyte_swapfile(); do_nothing_loop(); totally_screw_up_HPFS_file_system(); search_and_destroy_the_rest_of-OS2(); make_futile_attempt_to_damage_Linux(); disable_Netscape(); disable_RealPlayer(); disable_Lotus_Products(); hang_system(); } //if write_something(anything); display_copyright_message(); do_nothing_loop(); do_some_stuff(); if (still_not_crashed) { display_copyright_message(); do_nothing_loop(); basically_run_windows_31(); do_nothing_loop(); } // if } //while if (detect_cache()) disable_cache(); if (fast_cpu()) { set_wait_states(lots); set_mouse(speed,very_slow); set_mouse(action,jumpy); set_mouse(reaction,sometimes); } //if /* printf("Welcome to Windows 3.1"); */ /* printf("Welcome to Windows 3.11"); */ /* printf("Welcome to Windows 95"); */ /* printf("Welcome to Windows NT 3.0"); */ /* printf("Welcome to Windows 98"); */ /* printf("Welcome to Windows NT 4.0"); */ printf("Welcome to Windows 2000"); if (system_ok()) crash(to_dos_prompt) else system_memory = open("a:\swp0001.swp",O_CREATE); while(something) { sleep(5); get_user_input(); sleep(5); act_on_user_input(); sleep(5); } // while create_general_protection_fault(); } // main |