⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 field06-1.cpp

📁 数据结构常用算法合集
💻 CPP
字号:
 //field06-1.cpp   						设置科学计数法
 #include <iostream.h>					//cout
 #include <conio.h>						//getch()
 void main()
 { double sec;
   int secl;
   cout.setf(ios::scientific,ios::floatfield);	//设置科学符号
   cout.precision(2);  		          		 	//设置小数位数两位
   secl = 365 * 24 * 60 * 60;			 			//一年秒数
   sec = secl;									//转换为double
   cout << sec << endl;				 			//输出科学符号 3.15e+07
   cout.setf(ios::hex,ios::basefield);			//输出十六进制
   cout.setf(ios::showbase);						//输出基为0X
   cout.unsetf(ios::uppercase);					//以小写输出
   cout << secl << endl;                 			//0X1E13880
   cout.setf(ios::dec,ios::basefield);			//恢复输出十进制
   //或cout.unsetf(ios::basefield);
   cout << secl << endl;							//31536000
   getch();										//暂停
 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -