C++ Primer练习题day2
/*
1.7略
1.8
/*
指出不合法的语句;
std::cout<<"/";
std::cout<<"*/ ";
std::cout<</*" */"*/;
std::cout<</*"*/*"/*"*/;
1,2合法,3很明显中间插了个注释所以编译器会有相关的提示报错因为字符结构不完整
4.可以正常输出
*/
PS F:\DATA\primier> cd "f:\DATA\primier\" ; if ($?) { g++ c.cpp -o c } ; if ($?) { .\c
}
c.cpp:4:21: warning: missing terminating " character
std::cout<</*"*/"*/;
^
c.cpp:4:21: error: missing terminating " character
std::cout<</*"*/"*/;
^~~~
c.cpp: In function 'int main()':
c.cpp:6:1: error: expected primary-expression before '}' token
}
上面是第三个的输出
PS F:\DATA\primier> cd "f:\DATA\primier\" ; if ($?) { g++ c.cpp -o c } ; if ($?) { .\c
}
/*
这是第四个的输出
#include<iostream>
int main()
{
// std::cout<</*"*/"*/;
std::cout<</*"*/"/*"/*"*/;
}
验证程序,Markdown的问题显示可能有些错误
/*
1.9while循环50+到100
*/
#include<iostream>
int main()
{
int total=0;
int tar=50;
while(tar<=100)
{
total+=tar;
tar++;
}
std::cout<<"total is anwser:"<<total<<std::endl;
}
PS F:\DATA\primier> cd "f:\DATA\primier\" ; if ($?) { g++ c.cpp -o c } ; if ($?) { .\c
}
total is anwser:3825
/*
1.10--的使用
*/
#include<iostream>
int main()
{
int a=10;
while(a>=0)
{
std::cout<<a<<" ";
a--;
}
return 0;
}
PS F:\DATA\primier> cd "f:\DATA\primier\" ; if ($?) { g++ c.cpp -o c } ; if ($?) { .\c
}
10 9 8 7 6 5 4 3 2 1 0
C++ Primer练习题day2的更多相关文章
- python练习题-day2
1.判断下列逻辑语句的True,False 1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 True ...
- C++ Primer练习题day1
/* 练习1.1略 练习1.2.改写程序,让他返回-1. 练习1.3.编写程序,在标准的输出上打印Hello,World. */ #include<iostream> int main() ...
- c++primer练习题
2.7 输出地址和姓名(1 #include <iostream> using namespace std; int main() { int 距离; cout << &quo ...
- C/C++:多个.cpp文件包括同一个.h头文件定义方法
本文解决multiple definition of `XX'的错误.[出于反爬虫的目的,你不是在http://blog.csdn.net/zhanh1218上看到的,肯定不是最新最全的.] 关于头文 ...
- C++PRIMER第五版练习题答案第一章
C++PRIMER第五版练习题答案第一章 应该有很多小伙伴和我一样,闲来无事买了本C++的书自己啃,课后的练习题做的很揪心,这里我分享下我写的答案,希望能帮助到你,提供源码,就不跑了哈,毕竟现在是第一 ...
- Python之路 day2 字典练习题之 三级菜单
#Author:ersa ''' 程序: 三级菜单 要求: 打印省.市.县三级菜单 可返回上一级 可随时退出程序 ''' menu = { '北京':{ '海淀':{ '五道口':{ 'soho':{ ...
- C primer plus 练习题 第七章
1. #include <stdio.h> #define SPACE ' ' #define NEWLINE '\n' int main() { int spaces,newlines, ...
- C primer plus 练习题 第六章
16. #include <stdio.h> int main() { double remain = 100.0; ; ) { remain = remain * 0.08 + rema ...
- C primer plus 练习题 第五章
1. #include <stdio.h> #define MINU 60 int main() { int minute, hour, m; printf("请输入分钟:&qu ...
随机推荐
- openssl 模块 安装 centso Ubuntu
备忘: centos: yum install openssl-devel ubuntu: apt-get install libssl-dev 哎... 这玩意总是记不住. 每次都得搜索好麻烦.
- JS 时间转换函数 字符串时间转换毫秒(互转)
字符串转化为日期 let util = function(){ Date.prototype.Format = function(fmt) { var o = { "M+" : t ...
- hive的两种使用方式
hive的两种使用方式 1,hive shell的方式 启动命令: bin/hive 2.beeline客户端方式 首先在一个机器上启动hive thrift服务 bin/hiveserver2 在其 ...
- C语言学习笔记8-函数
C语言学习笔记8-函数 ...待编辑 1.汇编看函数调用过程 2.函数调用过程图示:学好C这个是关键,要懂得原理 标准调用(_cdecl) 参数由右往左入栈,调用者平衡栈(即入多少参数后参数调用玩后 ...
- codeforces gym #101161F-Dictionary Game(字典树+树上删边游戏)
题目链接: http://codeforces.com/gym/101161/attachments 题意: 给一个可以变化的字典树 在字典树上删边 如果某条边和根节点不连通那么这条边也删除 谁没得删 ...
- vue 图片上传
功能说明: 1.调用手机拍照功能 2.调用相册功能 3.图片上传功能 4.图片预览功能 5.图片删除功能 关键点: .input 新增multiple .accept="image/*处理I ...
- WGAN实验环境搭建
"TensorFlow在Windows上支持Python 3.5.x和3.6.x." 因此,您无法在Windows上使用Python 2.7的tensorflow windows+ ...
- nginx - nginx下配置thinkphp5
首先tp5的访问目录指向到webroot/public文件夹中.thinkphp的url访问:http://serverName/index.php(或者其它应用入口文件)/模块/控制器/操作/[参数 ...
- vue的路由认识
this.$router.options.routes //获得整个路由路径对象 this.$route.matched //获得当前路由的路径对象
- 一百三十二:CMS系统之前端动态获取后台添加的轮播图
先准备几张轮播图 排序顺序改为根据优先级倒序排 前端首页接口 @bp.route('/')def index(): banners = BannerModel.query.order_by(Banne ...