Skip to content

Instantly share code, notes, and snippets.

@Battleroid
Created April 8, 2013 00:47
Show Gist options
  • Save Battleroid/5333368 to your computer and use it in GitHub Desktop.
Save Battleroid/5333368 to your computer and use it in GitHub Desktop.
Just some miscellaneous stuff.
// 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;
}
// 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