Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › The Programming Challenge Master Thread
New Posts  All Forums:Forum Nav:

The Programming Challenge Master Thread - Page 20

post #191 of 244
Yes, as Waffleboy said goto is basically no-no in anything other than assembly.
Footrest
(17 items)
 
HTPC
(15 items)
 
 
CPUMotherboardGraphicsRAM
i3-2100T Asus P8H61-I Integrated Geil Black Dragon 1333 2x2GB 
Hard DriveHard DriveOptical DriveCooling
Seagate Barracuda 7200.11 500GB Western Digital Caviar Green 2TB OEM Slim DVD Burner Scythe Big-Shuriken 
OSMonitorKeyboardPower
Windows 7 Panasonic 42" HDTV Lenovo n5901a 300W PSU with the case 
Case
Silverstone SG-05 
  hide details  
Reply
Footrest
(17 items)
 
HTPC
(15 items)
 
 
CPUMotherboardGraphicsRAM
i3-2100T Asus P8H61-I Integrated Geil Black Dragon 1333 2x2GB 
Hard DriveHard DriveOptical DriveCooling
Seagate Barracuda 7200.11 500GB Western Digital Caviar Green 2TB OEM Slim DVD Burner Scythe Big-Shuriken 
OSMonitorKeyboardPower
Windows 7 Panasonic 42" HDTV Lenovo n5901a 300W PSU with the case 
Case
Silverstone SG-05 
  hide details  
Reply
post #192 of 244
Quote:
Originally Posted by Aximous View Post

Yes, as Waffleboy said goto is basically no-no in anything other than assembly.

You need them in BASIC as well.
Server
(10 items)
 
  
CPUMotherboardRAMHard Drive
Intel Xeon E3110 ASUS P5Q Premium 8GB G.Skill DDR2-800 2TB Caviar Green 
Hard DriveCoolingOSCase
1TB Caviar Black Prolimatech Megahalems VMWare ESX CM Stacker STC-T01 
OtherOther
LSI 9280-16i4e RAID Card Intel Pro/1000 PT Quad-Port Gigabit NIC 
  hide details  
Reply
Server
(10 items)
 
  
CPUMotherboardRAMHard Drive
Intel Xeon E3110 ASUS P5Q Premium 8GB G.Skill DDR2-800 2TB Caviar Green 
Hard DriveCoolingOSCase
1TB Caviar Black Prolimatech Megahalems VMWare ESX CM Stacker STC-T01 
OtherOther
LSI 9280-16i4e RAID Card Intel Pro/1000 PT Quad-Port Gigabit NIC 
  hide details  
Reply
post #193 of 244
Ah yes, forgot that one.
Footrest
(17 items)
 
HTPC
(15 items)
 
 
CPUMotherboardGraphicsRAM
i3-2100T Asus P8H61-I Integrated Geil Black Dragon 1333 2x2GB 
Hard DriveHard DriveOptical DriveCooling
Seagate Barracuda 7200.11 500GB Western Digital Caviar Green 2TB OEM Slim DVD Burner Scythe Big-Shuriken 
OSMonitorKeyboardPower
Windows 7 Panasonic 42" HDTV Lenovo n5901a 300W PSU with the case 
Case
Silverstone SG-05 
  hide details  
Reply
Footrest
(17 items)
 
HTPC
(15 items)
 
 
CPUMotherboardGraphicsRAM
i3-2100T Asus P8H61-I Integrated Geil Black Dragon 1333 2x2GB 
Hard DriveHard DriveOptical DriveCooling
Seagate Barracuda 7200.11 500GB Western Digital Caviar Green 2TB OEM Slim DVD Burner Scythe Big-Shuriken 
OSMonitorKeyboardPower
Windows 7 Panasonic 42" HDTV Lenovo n5901a 300W PSU with the case 
Case
Silverstone SG-05 
  hide details  
Reply
post #194 of 244
hello, i typed C++,C++ by accident, while i meant "C++,Lua", could you edit please?
    
CPUGraphicsRAMHard Drive
AMD Turion II X2 P540 ATI Mobility Radeon HD5650 Kingston 3GB DDR3 500 GB 5400rpm drive 
Optical DriveCoolingOSMonitor
DVD Super Multi DL Silent fan that barely gets the job done W7 HP 64bit 1336x768 15.6" 
  hide details  
Reply
    
CPUGraphicsRAMHard Drive
AMD Turion II X2 P540 ATI Mobility Radeon HD5650 Kingston 3GB DDR3 500 GB 5400rpm drive 
Optical DriveCoolingOSMonitor
DVD Super Multi DL Silent fan that barely gets the job done W7 HP 64bit 1336x768 15.6" 
  hide details  
Reply
post #195 of 244
Quote:
Originally Posted by Aximous View Post

Yes, as Waffleboy said goto is basically no-no in anything other than assembly.

Not quite, it's taboo because it did a lot of harm before, specially on languages with half-assed labels, but with enough experience and on certain specific scenarios, using goto creates more readable code that better mirrors the algorithm they are implementing.

NOTE: If studying CS, don't even try it, even if you're good enough to pull it off cleanly, teachers will hang you... specially ones that where around at the time of the goto-inquisition tongue.gif

Source to my words: Linus Torvalds on "Linux: Using goto In Kernel Code"
Back in Black
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II X4 965 BE (C3) Biostar TA790GX A3+ Sapphire HD 5770 (v2) CORSAIR XMS3 4GB DDR3 
Hard DriveOptical DriveOSMonitor
WD Caviar Black 640GB Sony Optiarc CD/DVD RW Windows 7 Ultimate x64 NEC MultiSync LCD 1960NXi 
KeyboardPowerCaseMouse
Microsoft Comfort Curve Keyboard 2000 Corsair 650TX Cooler Master Storm Scout Logitech MX 400 Laser 
  hide details  
Reply
Back in Black
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II X4 965 BE (C3) Biostar TA790GX A3+ Sapphire HD 5770 (v2) CORSAIR XMS3 4GB DDR3 
Hard DriveOptical DriveOSMonitor
WD Caviar Black 640GB Sony Optiarc CD/DVD RW Windows 7 Ultimate x64 NEC MultiSync LCD 1960NXi 
KeyboardPowerCaseMouse
Microsoft Comfort Curve Keyboard 2000 Corsair 650TX Cooler Master Storm Scout Logitech MX 400 Laser 
  hide details  
Reply
post #196 of 244
Anyhow, my code worked.
Success in my eyes rolleyes.gif

Sent from my GT-I9100 using Tapatalk 2
Citra ♥
(15 items)
 
Big Mac
(10 items)
 
 
CPUMotherboardGraphicsRAM
[Intel] Core i7 2600K [Asus] P8Z68-V Pro [Gainward] Geforce 9800 GTX+ [Corsair] Vengeance 16GB @ 1600 
Hard DriveHard DriveCoolingOS
[Kingston] HyperX 120GB SSD [Intel] 520 series 60GB [Corsair] H80 [Canonical] Ubuntu 12.10 
MonitorKeyboardPowerCase
[BenQ] XL2420T [Corsair] Vengeance K60 Performance [OCZ] ZX 850W [CM] Storm Enforcer 
MouseAudioOther
[Razer] Mamba 4G 2012 [Beats] urBeats [NZXT] 24/8/6 pin extensions 
CPUMotherboardGraphicsRAM
[Intel] Core i5-3210M [Apple] Proprietary [Intel] HD 4000 [Hynix] H5TC2G83CFR DDR3L 8GB 
Hard DriveOSMonitorKeyboard
[Samsung] 128GB SSD [Apple] OS X 10.8.2 ML 13" 2560x1600 Retina [Apple] Backlit Keyboard 
CaseMouse Pad
[Apple] Unibody [Apple] Trackpad 
  hide details  
Reply
Citra ♥
(15 items)
 
Big Mac
(10 items)
 
 
CPUMotherboardGraphicsRAM
[Intel] Core i7 2600K [Asus] P8Z68-V Pro [Gainward] Geforce 9800 GTX+ [Corsair] Vengeance 16GB @ 1600 
Hard DriveHard DriveCoolingOS
[Kingston] HyperX 120GB SSD [Intel] 520 series 60GB [Corsair] H80 [Canonical] Ubuntu 12.10 
MonitorKeyboardPowerCase
[BenQ] XL2420T [Corsair] Vengeance K60 Performance [OCZ] ZX 850W [CM] Storm Enforcer 
MouseAudioOther
[Razer] Mamba 4G 2012 [Beats] urBeats [NZXT] 24/8/6 pin extensions 
CPUMotherboardGraphicsRAM
[Intel] Core i5-3210M [Apple] Proprietary [Intel] HD 4000 [Hynix] H5TC2G83CFR DDR3L 8GB 
Hard DriveOSMonitorKeyboard
[Samsung] 128GB SSD [Apple] OS X 10.8.2 ML 13" 2560x1600 Retina [Apple] Backlit Keyboard 
CaseMouse Pad
[Apple] Unibody [Apple] Trackpad 
  hide details  
Reply
post #197 of 244
I know its only the first challenge, but I gotta start somewhere!
Code:
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
        int amount = 0;
        int i;
        int b;
        cout << "Enter amount of asterisks you want to display (Must be greater than 0): ";
        cin >> amount;

        if (amount < 1)
        {
                cout << "Error, input is invalid. Reinitiate program.";
        }
        else 
        {
                for (i = 1; i <= amount; i++)
                {
                        for(b = 1; b <= i; b++)
                        {
                                cout<< "* ";
                                
                        }
                        cout << endl;
                }

                amount = amount - 1;

                for (i = amount; i > -1; i--)
                {
                        for(b = 1; b <= i; b++)
                        {
                                cout<< "* ";
                                
                        }
                        cout << endl;
                }
        }

        system("pause");
        return 0;
}

thumb.gif
 
My first rig!
(16 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i5 2500K SABERTOOTH P67 NVIDIA GeForce GTX 480 NVIDIA GeForce GTX 480 
RAMRAMHard DriveHard Drive
Corsair  Corsair  500GB HDD 7200rpm M4 Crucial 
Optical DriveCoolingOSMonitor
None Hyper 212 plus Win7 x64 Viewsonic "23 or "24 1080p 
Case
CoolerMaster HAF 912 
CPUMotherboardGraphicsRAM
FX 4100 MSI 970A-G45 EVGA GTX 460 8 GB Corsair Vengeance 1600 MHz 
Hard DriveOptical DriveCoolingCooling
500GB Hard Drive USB DVD/CD Corsair H50 Graphics card aftermarket cooler 
OSMonitorKeyboardPower
Win 7 x64 ViewSonic 24" Logitech 500W CoolerMaster 
CaseMouseAudioOther
NVIDIA Elite 334 LG Old speakers USB Lamp 
  hide details  
Reply
 
My first rig!
(16 items)
 
 
CPUMotherboardGraphicsGraphics
Intel Core i5 2500K SABERTOOTH P67 NVIDIA GeForce GTX 480 NVIDIA GeForce GTX 480 
RAMRAMHard DriveHard Drive
Corsair  Corsair  500GB HDD 7200rpm M4 Crucial 
Optical DriveCoolingOSMonitor
None Hyper 212 plus Win7 x64 Viewsonic "23 or "24 1080p 
Case
CoolerMaster HAF 912 
CPUMotherboardGraphicsRAM
FX 4100 MSI 970A-G45 EVGA GTX 460 8 GB Corsair Vengeance 1600 MHz 
Hard DriveOptical DriveCoolingCooling
500GB Hard Drive USB DVD/CD Corsair H50 Graphics card aftermarket cooler 
OSMonitorKeyboardPower
Win 7 x64 ViewSonic 24" Logitech 500W CoolerMaster 
CaseMouseAudioOther
NVIDIA Elite 334 LG Old speakers USB Lamp 
  hide details  
Reply
post #198 of 244
MOAR!!!!

Seriously when is the next challenge?
Back in Black
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II X4 965 BE (C3) Biostar TA790GX A3+ Sapphire HD 5770 (v2) CORSAIR XMS3 4GB DDR3 
Hard DriveOptical DriveOSMonitor
WD Caviar Black 640GB Sony Optiarc CD/DVD RW Windows 7 Ultimate x64 NEC MultiSync LCD 1960NXi 
KeyboardPowerCaseMouse
Microsoft Comfort Curve Keyboard 2000 Corsair 650TX Cooler Master Storm Scout Logitech MX 400 Laser 
  hide details  
Reply
Back in Black
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Phenom II X4 965 BE (C3) Biostar TA790GX A3+ Sapphire HD 5770 (v2) CORSAIR XMS3 4GB DDR3 
Hard DriveOptical DriveOSMonitor
WD Caviar Black 640GB Sony Optiarc CD/DVD RW Windows 7 Ultimate x64 NEC MultiSync LCD 1960NXi 
KeyboardPowerCaseMouse
Microsoft Comfort Curve Keyboard 2000 Corsair 650TX Cooler Master Storm Scout Logitech MX 400 Laser 
  hide details  
Reply
post #199 of 244
Thread Starter 
Quote:
Originally Posted by Chris++ View Post

MOAR!!!!
Seriously when is the next challenge?

Soon. I've just been a bit busy...actually a bit more lazy than busy, but you get the point. biggrin.gif
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
post #200 of 244
Quote:
Originally Posted by {Unregistered} View Post

Yea, that through me off a bit when I first read his code.
I don't think I've ever really seen GOTOs used in C++.

blaaaah.. Knowing that my code wasn't made correctly was driving me nuts, so here I am, once again nerdsmiley.png
Does this look better to you?

Warning: Spoiler! (Click to show)
Code:
void OCN1(int input){
    int i = input;
    string chr = "*";
    
    for(int p = 0; p < input; p++){
        cout << chr << endl;
        chr += "*";
    }
        
    for(int m = input; (m = input); i--){
        cout << chr << endl;
        chr.erase(i);
    }
}

Edited by bruflot - 7/9/12 at 1:30pm
Citra ♥
(15 items)
 
Big Mac
(10 items)
 
 
CPUMotherboardGraphicsRAM
[Intel] Core i7 2600K [Asus] P8Z68-V Pro [Gainward] Geforce 9800 GTX+ [Corsair] Vengeance 16GB @ 1600 
Hard DriveHard DriveCoolingOS
[Kingston] HyperX 120GB SSD [Intel] 520 series 60GB [Corsair] H80 [Canonical] Ubuntu 12.10 
MonitorKeyboardPowerCase
[BenQ] XL2420T [Corsair] Vengeance K60 Performance [OCZ] ZX 850W [CM] Storm Enforcer 
MouseAudioOther
[Razer] Mamba 4G 2012 [Beats] urBeats [NZXT] 24/8/6 pin extensions 
CPUMotherboardGraphicsRAM
[Intel] Core i5-3210M [Apple] Proprietary [Intel] HD 4000 [Hynix] H5TC2G83CFR DDR3L 8GB 
Hard DriveOSMonitorKeyboard
[Samsung] 128GB SSD [Apple] OS X 10.8.2 ML 13" 2560x1600 Retina [Apple] Backlit Keyboard 
CaseMouse Pad
[Apple] Unibody [Apple] Trackpad 
  hide details  
Reply
Citra ♥
(15 items)
 
Big Mac
(10 items)
 
 
CPUMotherboardGraphicsRAM
[Intel] Core i7 2600K [Asus] P8Z68-V Pro [Gainward] Geforce 9800 GTX+ [Corsair] Vengeance 16GB @ 1600 
Hard DriveHard DriveCoolingOS
[Kingston] HyperX 120GB SSD [Intel] 520 series 60GB [Corsair] H80 [Canonical] Ubuntu 12.10 
MonitorKeyboardPowerCase
[BenQ] XL2420T [Corsair] Vengeance K60 Performance [OCZ] ZX 850W [CM] Storm Enforcer 
MouseAudioOther
[Razer] Mamba 4G 2012 [Beats] urBeats [NZXT] 24/8/6 pin extensions 
CPUMotherboardGraphicsRAM
[Intel] Core i5-3210M [Apple] Proprietary [Intel] HD 4000 [Hynix] H5TC2G83CFR DDR3L 8GB 
Hard DriveOSMonitorKeyboard
[Samsung] 128GB SSD [Apple] OS X 10.8.2 ML 13" 2560x1600 Retina [Apple] Backlit Keyboard 
CaseMouse Pad
[Apple] Unibody [Apple] Trackpad 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › The Programming Challenge Master Thread