Reply
Stuck on a Dotted Slope Generator
Old 01-10-2009, 06:03 PM Stuck on a Dotted Slope Generator
Decaf's Avatar
Ultra Talker

Posts: 490
Name: Adam
Trades: 0
Agh... My C++ class has asked me to provide an example of a "cool" script (we are 2 days in), so i had the idea for a simple dotted line generator. The script works fine in PHP

PHP Code:
<?php
# Config
$max 250;
?>
<html>
<!--
    # Dotted Slope Generator
    # Made By Adam Shannon
    # http://ashannon.us
    # adam@ashannon.us
    COPYRIGHT 2009 ALL RIGHTS RESERVED!!!
-->
<head>
<title>Dotted Slope Generator</title>
<style type="text/css">
h3 {text-align:center;}
</style>
</head>
<body>
<h3>Dotted Slope Generator</h3>
<?php
# Load sacred Vars
$row 1;
$col 1;
# Start
while ($row<$max+2) {
# If the loop is just starting, don't print anything.
    
if ($row != 1) {print $row-") ";}
# Start the major loop
    
while ($col<$row) {
    
# Print each dot
        
print ".";
    
$col++;
    }
# Reset for next line
$col 1;
$row++;
    print 
"<br />\n";
}
# End
?>
</body>
</html>
But when i try to convert it to C++ it makes an infinite loop.

PHP Code:
/*
    # Dotted Slope Generator
    # Made By Adam Shannon
    # http://ashannon.us
    # adam@ashannon.us
    COPYRIGHT 2009 ALL RIGHTS RESERVED!!!
*/

// Load Header Files/Commands
#include <iostream>
using namespace std;

// Begin
int main() {
    
// Load Vars
    
int max '10';
    
int row '1';
    
int col '1';
    
char end;
    
char start;

    
// Title Message
        
cout << "\t\t\t\tDotted Slope Generator\n";
        
cout << "Enter a character to start.";
        
cin >> start;
// Begin Loop
while (row max) {

// Start the major loop
        
while (col row) {
            
// Print each dot
            
cout << ".";
        
col++;
        }

// Reset for next line
    
col '1';
    
row++;
    
cout << "\n";
}

// Pause till exit command.
cout << "Enter a character to exit.";
cin >> end;

return 
0;
}
// End 
</span>
__________________
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
 
When You Register, These Ads Go Away!
Reply     « Reply to Stuck on a Dotted Slope Generator
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.11167 seconds with 13 queries