摘要:
/*主要内容: 1.算术运算的优先级 2.算术声明的缺陷 3.在算术表达式中混合整数和实数 4.类型强制转换 5.边缘效应*/#include<iostream>usingnamespace std;int main(){ int i=1,j=1, k1=10,k2=20,k3=30,k4=40,k5=50, k,h,m,n; double a=7,b=6,c=5,d=4, e,p,q,x,y,z; cout<<"*********Section 1*********... 阅读全文
posted @ 2012-06-21 17:54
蚂蚁踩死了大象
阅读(148)
评论(0)
推荐(0)
摘要:
#include<iostream>usingnamespace std;int main(){ int i,j,k,p,m,n; double a,b,c,d,e,f,g,h,x,y,z; i=5; j=5; k=11; p=3; x=3.0; y=4.0; cout<<"---------Section 1 output" "-------"<<endl<<endl; a=x+y; b=x-y; c=x*y; d=x/y; e=d+3.0; f=d+3; i=i+1; j=j... 阅读全文
posted @ 2012-06-21 16:11
蚂蚁踩死了大象
阅读(91)
评论(0)
推荐(0)
摘要:
#include<iostream>usingnamespace std;int main(){ char c1,c2,c3,c4,c5,c6; int i,j; c1='g'; c2='<'; c3='\n';//转义序列("newline")\n被c++看作单个字符,输出时,不显示任何字符,光标只是跳至新的行。 c4='7';//结果为7 c5=63; c6=c1-3; i=c4;//结果为55 j=c4+2;//结果为57 cout<<"c1="<& 阅读全文
posted @ 2012-06-21 16:09
蚂蚁踩死了大象
阅读(93)
评论(0)
推荐(0)
摘要:
//创建常量以及更多显示变量值的信息。#include<iostream>#include<iomanip>usingnamespace std;int main(){ constdouble PI=3.1415926; cout<<"1.PI=[["<<PI<<"]]"<<endl; cout<<"2.PI=[["<<setw(15)<<PI<<"]]"<<endl;//域宽为15空 阅读全文
posted @ 2012-06-21 16:06
蚂蚁踩死了大象
阅读(122)
评论(0)
推荐(0)
摘要:
#include<iostream>usingnamespace std;int main(){ int tank_id;//使用关键字int将变量(tank_id)声明为整型 double diameter,pressure;//使用关键字double将变量(diameter和pressure)声明为实数 tank_id=12; diameter=111.1; pressure=100;//赋值语句使用=符号将数值存储在被声明的变量的内存单元中 cout<<"Tank_id="<<tank_id<<",Diamet 阅读全文
posted @ 2012-06-21 15:58
蚂蚁踩死了大象
阅读(132)
评论(0)
推荐(0)
摘要:
#include<iostream>usingnamespace std;int main(){ cout<<"This is";//看到这两个语句的输出结果,即使语句占两行, cout<<"C++!"; // 但输出结果仍为一行,且注意到输出中"is"和"C++"之间没有空格。 cout<<"\nWE can\njump\n\ntwo lines."; cout<<endl; cout<<"Here,we sho 阅读全文
posted @ 2012-06-21 15:57
蚂蚁踩死了大象
阅读(154)
评论(0)
推荐(0)
摘要:
#include<iostream> //该行告知,程序包含了输入和输出库函数。usingnamespace std; //该行允许更好地访问C++内部资源,如输入和输出。int main() //该行表示main函数就要开始了。{ //该大括号开始一段代码块,这里是main函数体的开始。 cout<<"This is c++!"; //该行在屏幕上输出“This is C++!”。 return0;//} //该大括号结... 阅读全文
posted @ 2012-06-21 15:48
蚂蚁踩死了大象
阅读(186)
评论(0)
推荐(0)

浙公网安备 33010602011771号