摘要:
/*1.逻辑运算符的使用。 2.逻辑表达式的使用。*/#include<iostream>usingnamespace std;int main(){ int x=5,y=0; cout<<"x="<<x<<",y="<<y<<endl; if(x>0&&y>0)//使用了运算符'与'=&&. cout<<"x is greater than 0 and" "y is greater 阅读全文
posted @ 2012-06-22 21:35
蚂蚁踩死了大象
阅读(113)
评论(0)
推荐(0)
摘要:
//嵌套的if-else控制结构#include<iostream>usingnamespace std;int main(){ int day; double time; cout<<"Type the day and time of interest"<<endl; cin>>day>>time; if(day<=5) { if(time<=9.00) cout<<"Drive piles"<<endl; else cout<<"Co 阅读全文
posted @ 2012-06-22 21:03
蚂蚁踩死了大象
阅读(149)
评论(0)
推荐(0)
摘要:
/*1.简单的if-else控制结构2.条件运算符"?:"*/#include<cmath>#include<iostream>#include<iomanip>usingnamespace std;int main(){ double revenue=0,expenses=0,profit=0,loss=0,interest=0; cout<<setprecision(2)<<setiosflags(ios::showpoint); cout<<"Enter the company' 阅读全文
posted @ 2012-06-22 20:26
蚂蚁踩死了大象
阅读(133)
评论(0)
推荐(0)
摘要:
/*1.简单的if语句。 2.if语句块。 3.控制程序流。 4.关系运算符 5.关系表达式。*/#include<iostream>usingnamespace std;int main(){ int pcode_entered; constint pcode=8765; cout<<"Enter your pass code."<<endl; cin>>pcode_entered; if(pcode_entered<pcode) cout<<"Incorrect code" " 阅读全文
posted @ 2012-06-22 19:34
蚂蚁踩死了大象
阅读(148)
评论(0)
推荐(0)
摘要:
#include<iostream>usingnamespace std;int main(){ char c1,c2,c3,c4; cout<<"Enter your first,middle and last initials"<<endl;//注意提醒用户输入的信息。 cin>>c1>>c2>>c3;//从键盘读取字符。 cout<<"You entered"<<c1<<c2<<c3<<endl; cout<&l 阅读全文
posted @ 2012-06-22 18:14
蚂蚁踩死了大象
阅读(131)
评论(0)
推荐(0)
摘要:
#include<iostream>#include<fstream>usingnamespace std;int main(){ double x; int i,j; ifstream infile1("A.txt"); ifstream infile2("B.txt");//声明从什么文件中读取数据。 infile>>i; infile>>j>>x;//注意:读取、读入文件信息使用的符号不一样。 infile.close(); cout<<"From first fil 阅读全文
posted @ 2012-06-22 17:57
蚂蚁踩死了大象
阅读(118)
评论(0)
推荐(0)
摘要:
#include<iostream>#include<fstream>//使用用于文件输入和输出的fstream头文件。usingnamespace std;int main(){ double income=123.45,expenses=987.65; int week=7,year=2006; ofstream outfile("A.txt");//写入文件。 outfile<<"Week="<<week<<endl;<<"Year=" <<ye 阅读全文
posted @ 2012-06-22 17:32
蚂蚁踩死了大象
阅读(182)
评论(0)
推荐(0)
摘要:
/*从键盘读取数据 1.使用cin对象从键盘输入数据 2.提示输入*/#include<iostream>#include<iomanip>usingnamespace std;int main(){ double income,expense; int month; cout<<"What month is it?"<<endl; cin>>month; cout<<"You have entered the month="<<month<<endl; co 阅读全文
posted @ 2012-06-22 10:49
蚂蚁踩死了大象
阅读(197)
评论(0)
推荐(0)
摘要:
#include<iostream>#include<cmath>//包括数学函数的头文件。#include<iomanip>usingnamespace std;int main(){ double x=3.0,y=4.0; double a,b,c,d,e,f; float g; a=sin(x); b=exp(x); c=log(x); d=sqrt(x); e=pow(x,y); f=sin(y)+exp(x)-log10(y)*sqrt(y)/pow(3.2,4.4); g=log(x);//注意,c和g值相同,但是类型不同... 阅读全文
posted @ 2012-06-22 10:20
蚂蚁踩死了大象
阅读(176)
评论(0)
推荐(0)

浙公网安备 33010602011771号