Created
April 8, 2013 00:47
-
-
Save Battleroid/5333368 to your computer and use it in GitHub Desktop.
Just some miscellaneous stuff.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fizzbuzz | |
#include <iostream> | |
using std::cout; | |
using std::endl; | |
int main () { | |
for (int i = 0; i <= 100; i++) { | |
if (i % 15 == 0) | |
cout << i << ": FizzBuzz"; | |
else if (i % 3 == 0) | |
cout << i << ": Fizz"; | |
else if (i % 5 == 0) | |
cout << i << ": Buzz"; | |
else | |
cout << i; | |
cout << endl; | |
} | |
system("pause"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Swapping without temporary variable | |
#include <iostream> | |
using std::cout; | |
using std::endl; | |
using std::cin; | |
int main () { | |
int a, b; | |
cout << "Enter two integers: "; | |
cin >> a >> b; | |
cout << "a: " << a << ", b: " << b << endl; | |
a = a + b; | |
b = a - b; | |
a = a - b; | |
cout << "a: " << a << ", b: " << b << endl; | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment