小白入门_老九(C++入门)P36~42

1# include
2# include
3# include
4# include <windows.h>
5# include
6# include
7#include
usin g namespace std;

int main()
{
int sum = 0;
for (int i = 0; i <= 100; i++) {
if (i % 2 != 0) {
continue;
}
sum = sum + i;
cout << i << endl;
}

/*double money;
int playerCount = 0;
for (int i = 0; i < 5; i++) {
	cout << "请输入当前玩家的消费数量:" << endl;
	cin >> money;
	if (money >= 500) {
		continue;
	}
playerCount++;
}
cout << "消费低于500的玩家的数量是:" << playerCount << endl;
getchar();*/

//break的例子
/*const double PRICE = 5000.0;
double guessPrice;
int guessCount=0;
for (;;) {
	guessCount++;
	cout << "enter your number:"<<endl;
	cin >> guessPrice;
	if (guessPrice == PRICE) {
		cout << "you are lucky"<<endl;
		break;
	}
	else if(guessPrice > PRICE){
		cout << "大了" << endl;
	}
	else {
		cout << "小了" << endl;
	}
}

if (guessCount < 5) {
	cout << "you are clever"<<endl;
}*/


/*int age;
for (;;) {
	cout << "enter your age:";
	cin >> age;
	if (age < 0) {
		cout << "输入的文件格式有误" << endl;
		break;
	}
}*/

/*int day = 31;
int dayofWeek = 2;
cout << "一\t二\t三\t四\t五\t六\t日" << endl;//编排星期序列
for (int i = 0; i < dayofWeek - 1; i++) {
	cout << '\t';
}
//打印日子
for (int i = 1; i <= day; i++) {
	cout << i;//经过观察,周一到周六之间用\t,而换行用\n
	if ((i + dayofWeek - 1) % 7 == 0) {
		cout << "\n";
	}
	else {
		cout << '\t';
	}
}
cout << endl;*/





/*int a = 1, b = 10;
do {
	b -= a;
	a++;
} while (b-- < 0);
cout << b << endl;
const int N = 20;//真常量
for (int i = 0; i < N; i++) {
	printf("再别康桥!\n");
}*/
/*double salary = 0;
double sumsalary = 0;
double avgSalary = 0;
const int YEAR = 6;
for (int i = 0; i < YEAR; i++)
{
	cout << "请输入第" << i + 1 << "月的工资" << endl;
	cin >> salary;
	sumsalary += salary;
}
avgSalary = sumsalary / YEAR;
cout << "六个月的平均工资为:" << avgSalary << endl;
getchar();*/

/*八的HP*/
/*int hp1 = 100;
int hp2 = 100;

int attack1 = 0;
int attack2 = 0;
int randNum;  //用于存放玩家攻击先后的随机数变量

srand(time(NULL));//时间函数   更新随机种子

while (hp1 > 0 && hp2 > 0) //当双方都生存的时候,继续战斗
{
	randNum = rand();
	//模拟玩家出招 科技采用随机数是奇数还是偶数来进行判断
	if (randNum % 2 == 1) {
		attack1 = (int)(5 + 10 * rand() / (RAND_MAX + 1.0));
		attack2 = (int)(5 + 10 * rand() / (RAND_MAX + 1.0));

		hp2 -= attack1;//互相掉血
		if (hp2 >= 90 && hp2 <= 100) {
			cout << "草皮镜状态良好" << endl;
		}
		hp1 -= attack2;
	}
	else {
		attack2 = (int)(5 + 10 * rand() / (RAND_MAX + 1.0));
		attack1 = (int)(5 + 10 * rand() / (RAND_MAX + 1.0));

		hp1 -= attack2;//互相掉血
		hp2 -= attack1;
	}
}

//2.打印最终的结果
cout << "八神HP:" << hp1 << endl;
cout << "操神HP:" << hp2 << endl;*/



/*double price_louis = 35000.0;
double price_hemes = 11044.5;
double price_chanel = 1535.0;
if ((price_chanel+price_hemes+price_louis))
char pan = '\0';
cout << "please enter a number:";
cin >> pan;
if (pan >= 'A'&&pan <= 'Z') {
	cout << "great";
}
else {
	cout << "no!";
}
cout << "Hello"<< "World!" << endl;
cout << "英雄名称:寒冰射手-埃希\n";
cout << "护甲:15.5(+3.4)\n"
	<< "生命值:395+5\t 生命恢复"<<endl;
cout << INT_MAX << endl;
cout << "口心思" << endl;
float num = 123464.46464;
cout << fixed << setprecision(2);
cout << num << endl;
cout << sizeof(long) << endl;
cout << sizeof(double) << endl;
SetConsoleTitle(TEXT("德玛西亚"));
double attack = 57.88;
double attack_growth = 4.5;
double attack_value = 172;
cout << "攻击数值" << "(+" << attack_value << "+)" << attack_growth << endl;
cout << !(((18 + 45 % 3 * 5) > 16)) << endl;
cout << sizeof("") << endl;*/
/*int choice = 1;
switch (choice) {
case 1:
	cout << "你选择了展示" << endl;
	//getchar();
	break;
case 2:
	cout << "你选择了展示" << endl;
	//getchar();
	break;
default:
	cout << "hdshalfha" << endl;
}

int i = 1;
while (i <= 10) {
	cout << "小人本住在苏州成本\t" << endl;
	cout << i << endl;
	i++;
}*/
/*int sum = 0;
int i = 1;
while(i < 101) {
	sum = sum + i;
	i++;
}
cout << sum << endl;*/
/*string password;
int i = 0;
while (i < 3) {
	cout << "please enter your password!:"<<endl;
	cin >> password;
	i++;
	if (password != "123456") {
		if (i == 3) {
			cout << "you have failed four times!" << endl;
			exit(123456);
		}
	}
	else {
		cout << "congratulation!" << endl;
		break;
		getchar();
	}
}*/
/*double money = 800.0;
int year = 2015;
while (money <= 2000) {
	year++;
	money = money*(1 + 0.25);
}
cout << "在第" << year << "年会获得2000亿元的结果" << endl;*/

getchar();
return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值