C++ 中的空格
只包含空格的行,被稱為空白行,可能帶有注釋,C++ 編譯器會完全忽略它。
在 C++ 中,空格用於描述空白符、制表符、換行符和注釋。空格分隔語句的各個部分,讓編譯器能識別語句中的某個元素(比如 int)在哪里結束,下一個元素在哪里開始。
1 #include <iostream> 2 #include <cmath> 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 4 using namespace std; 5 int main(int argc, char** argv) { 6 float a,b,c,x1,x2; 7 cin >>a >>b >>c; 8 x1=(-b+sqrt(b*b-4*a*c))/(2*a); 9 x2=(-b-sqrt(b*b-4*a*c))/(2*a); 10 cout <<"x1=" <<x1 <<endl; 11 cout <<"x2=" <<x2 <<endl; 12 return 0; 13 }