Last active
August 29, 2015 14:04
-
-
Save chomado/c7ff676fe1f42d4c8e3e to your computer and use it in GitHub Desktop.
テンプレート練習
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
#include <iostream> | |
using namespace std; | |
template <typename Type> Type square(Type x) | |
{ | |
return x * x; | |
} | |
int main() | |
{ | |
int a; | |
double b; | |
cout << "実数a: "; cin >> a; | |
cout << "実数b: "; cin >> b; | |
cout << "aの二乗は" << square(a) << "です。" << endl; | |
cout << "bの二乗は" << square(b) << "です。" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment