三不政策
不知道 不清楚 不要問我
long sum(long num1, long num2);
數學函數http://www.cplusplus.com/reference/cmath/
有範例
Example
|
|
Output:
Characters: a A Decimals: 1977 650000 Preceding with blanks: 1977 Preceding with zeros: 0000001977 Some different radices: 100 64 144 0x64 0144 floats: 3.14 +3e+000 3.141600E+000 Width trick: 10 A string |
|
|
This example demonstrates some of the types that can be read with scanf:
Enter your family name: Soulie Enter your age: 29 Mr. Soulie , 29 years old. Enter a hexadecimal number: ff You have entered 0xff (255). |
Example
|
|
Output:
3.1416 3.14159 3.14159 3.141590000 |
Example
|
|
Possible output:
bad_alloc caught: bad allocation |
Example
|
|
Output:
minmax({1,2,3,4,5}): 1 5 |
Example
|
|
Output:
min(1,2)==1 min(2,1)==1 min('a','z')==a min(3.14,2.72)==2.72 |
double最多308位數
位數超過1000
三角形判別
// ConsoleApplication7.cpp : 定義主控台應用程式的進入點。
//
//#include "stdafx.h"
/* printf example */
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int a[3];
int tmp;
cout << "enter 3 numbers";
cin >> a[0] >> a[1] >> a[2];
sort(a,a+3);
//int a(a[0]),b(a[1]),c(a[2]);
cout << a[0] << " " << a[1] << " " << a[2] << endl;
if (a[0] + a[1] <= a[2])
{
cout << "No" << endl;
}
else if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2])
{
cout << "Obtuse" << endl;
}
else if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
{
cout << "Right" << endl;
}
else if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2])
{
cout << "Acute" << endl;
}
return 0;
}
----------------------------------------------------
// ConsoleApplication7.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
/* printf example */
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
int a[3];
int tmp;
cout << "enter 3 numbers";
cin >> a[0] >> a[1] >> a[2];
for (int i = 3; i > 0; i--)
for (int i = 3; i > 0; i--)
{ //氣泡排序
for (int j = 0; j < i - 1; j++) {
if (a[j] > a[j + 1]) {
tmp = a[j];
a[j] = a[j + 1];
a[j + 1] = tmp;
}
}
}
cout << a[0] << " " << a[1] << " " << a[2] << endl;
if (a[0] + a[1] <= a[2])
{
cout << "No" << endl;
}
else if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2])
{
cout << "Obtuse" << endl;
}
else if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])
{
cout << "Right" << endl;
}
else if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2])
{
cout << "Acute" << endl;
}
return 0;
}
-------------------------------------------
// ConsoleApplication7.cpp : 定義主控台應用程式的進入點。
//
//#include "stdafx.h"
/* printf example */
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int s[3];
int tmp;
cout << "enter 3 numbers";
cin >> s[0] >> s[1] >> s[2];
sort(s,s+3);
int a(s[0]),b(s[1]),c(s[2]); //a有同名題
cout << a << " " << b << " " << c << endl;
if (a+ b <= c)
{
cout << "No" << endl;
}
else if (a * a + b * b < c * c)
{
cout << "Obtuse" << endl;
}
else if (a * a + b * b == c * c)
{
cout << "Right" << endl;
}
else if (a * a+ b * b < c * c)
{
cout << "Acute" << endl;
}
return 0;
}
---------------------------------
https://zh.wikipedia.org/wiki/ASCII
Funcition Overloading
變數不可同名
函數可以(靠資料格式)
int max(int x[],int len);
long max(long x[],int len)
//
//#include "stdafx.h"
/* printf example */
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int s[3];
int tmp;
cout << "enter 3 numbers";
cin >> s[0] >> s[1] >> s[2];
sort(s,s+3);
int a(s[0]),b(s[1]),c(s[2]); //a有同名題
cout << a << " " << b << " " << c << endl;
if (a+ b <= c)
{
cout << "No" << endl;
}
else if (a * a + b * b < c * c)
{
cout << "Obtuse" << endl;
}
else if (a * a + b * b == c * c)
{
cout << "Right" << endl;
}
else if (a * a+ b * b < c * c)
{
cout << "Acute" << endl;
}
return 0;
}
---------------------------------
https://zh.wikipedia.org/wiki/ASCII
Funcition Overloading
變數不可同名
函數可以(靠資料格式)
int max(int x[],int len);
long max(long x[],int len)
沒有留言:
張貼留言