当前位置: 首页 > news >正文

四川内江网站建设seo技术教程网

四川内江网站建设,seo技术教程网,wordpress评论不能用,网站开发设计大赛文章目录 1.c 程序结构关键字标识符、操作符、标点预处理指令注释main 主函数命名空间 2.c 变量和常量变量 3.c 数组和容器4.c 程序流程5.c字符和字符串 1.c 程序结构 关键字 关键字事程序保留的,程序员不能使用,c的常见关键字如下图: 标识…

文章目录

  • 1.c++ 程序结构
    • 关键字
    • 标识符、操作符、标点
    • 预处理指令
    • 注释
    • main 主函数
    • 命名空间
  • 2.c++ 变量和常量
    • 变量
  • 3.c++ 数组和容器
  • 4.c++ 程序流程
  • 5.c++字符和字符串

1.c++ 程序结构

在这里插入图片描述

关键字

关键字事程序保留的,程序员不能使用,c++的常见关键字如下图:
在这里插入图片描述

标识符、操作符、标点

在这里插入图片描述
:: 这个也是操作符,不是标点。

预处理指令

在这里插入图片描述

注释

在这里插入图片描述

main 主函数

一个程序只能有一个入口。
在这里插入图片描述
代码练手:

#include<iostream>using namespace std;int main(){cout << "hello" << endl;return 0;
}

代码练手

#include<iostream>
using namespace std;//argc 参数数量
//argv 参数列表
int main(int argc,char** argv){cout << "参数数量:" << argc << endl;cout << "==== 参数列表 =====" << endl;for (int i = 0;i < argc; i ++){cout << "参数:" <<argv[i] << endl;} return 0;
}

命名空间

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

想不发生冲突,还是直接std::cout,比较好一点。

2.c++ 变量和常量

在这里插入图片描述

变量

在这里插入图片描述
变量名实际上就是你的内存地址。只不过对于不同的对象就是在堆上还是在栈上。因为是一块地址,所以是可以变化的,想放什么就放什么。

在这里插入图片描述
在这里插入图片描述
变量的初始化。
在这里插入图片描述
代码演示:

#include<iostream>
using namespace std;int main(){int age;cout << "age is : " << age << endl;return 0;
}

如果变量没有初始化,会触发警告。如下图。警告不影响运行,但是最好都要做初始化。

在这里插入图片描述
代码练手,计算房子面积:

#include<iostream>
using namespace std;int main(){int room_width {0};cout << "请输入房间宽度:" ;cin >> room_width;int room_height {0};cout << "请输入房间高度" ;cin >> room_height;cout << "=====================" << endl;cout << "房间的面积是:" << room_height * room_width << endl;return 0;
}

数据基本类型都有哪些:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
附上ASCII编码表:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

变量声明的时候,因为变量是有大小限制的,如果声明的超过了范围,使用花括号,就会报错。如下图,这也是花括号声明的好处之一。

在这里插入图片描述
代码练手:

#include<iostream>
using namespace std;int main(){cout << "=====字符型" << endl;char my_char {'f'};cout << "字符:" << my_char << endl;cout << "=====短整型" << endl;short my_short {59};cout << "短整型:" << my_short << endl;// cout << "======浮点数======" << endl;// 不会报错short overflow_num_1 = 32769;cout << "短整型溢出" << overflow_num_1 << endl;// short overflow_num_2 {32768}; // 会报错,无法编译// cout <<  "短整型溢出" << overflow_num_2 << endl;cout << "########int#######" << endl;int my_height {182};cout << "int类型:" << my_height << endl;long peolple {10360000};cout << "杭州人数:" << peolple << endl;long long people_in_world {80'0000'0000}; // 方便阅读 c++14标准cout << "全世界的人数:" << people_in_world << endl;//浮点型cout << "=======浮点型=======" << endl;float book_price {24.21f};cout << "书的价格" << book_price << endl;double pi {3.14159};cout << "圆周率:" << pi << endl;cout << "#######bool#########" << endl;bool add_to_cart {true};cout << boolalpha; // 以bool值的形式输出cout << "是否加入购物车:" << add_to_cart << endl;return 0;
}
  • sizeof 和climits
  • 在这里插入图片描述
    代码示例:
#include<iostream>
using namespace std;
// 想要使用看大小的函数,需要引入climits
#include<climits>int main(){cout << "char:" << sizeof(char) << endl;cout << "short:" << sizeof(short) << endl;cout << "int:" << sizeof(int) << endl;cout << "long:" << sizeof(long) << endl;cout << "long long:" << sizeof(long long) << endl;cout << "float:" << sizeof(float) << endl;cout << "double:" << sizeof(double) << endl;cout << " min and max" << endl;cout << "char min:" << CHAR_MIN << ",max:" <<CHAR_MAX << endl;cout << "short min:" << SHRT_MIN << ",max:" <<SHRT_MAX << endl;cout << "long long min:" << LLONG_MIN << ",max:" << LLONG_MAX << endl;cout << "使用变量名称看大小" << endl;int age {11};cout << "age is : " << sizeof age << endl;cout << "age is : " << sizeof(age) << endl;double salary {123123.44};cout << "salary is : " << sizeof(salary) << endl;return 0;
}
  • 常量

在这里插入图片描述

代码练手:


#include<iostream>
using namespace std;int main(){const double pi {3.1415926};cout << "请输入半径:" ;double radius {};cin >> radius;cout << "圆的面积:" << pi * radius * radius << endl;
}

3.c++ 数组和容器

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
注意:访问的超出范围会报错。
在这里插入图片描述

代码演示:

#include<iostream>
using namespace std;int maopao(int array[]){// 写一段冒泡排序的代码return 0;
} int main(){char vowels[] {'a','e'};cout << "第1个元素:" << vowels[0] << endl;cout << "第2个元素:" << vowels[1] << endl;// cin >> vowels[2];// cout << "第3个元素:" << vowels[2] << endl;double hi_tmps [] {100,101,102,103};hi_tmps[0]= 200;cout << "第五天的温度:" << hi_tmps[4] << endl; // 放到到一个未知的地址空间,数据每次都不同int student_score[5];cout << "第一个学生的成绩是:" << student_score[0] << endl;cout << "第二个学生的成绩是:" << student_score[1] << endl;cout << "第三个学生的成绩是:" << student_score[2] << endl;cout << endl;cin >> student_score[0];cin >> student_score[1];cin >> student_score[2];cin >> student_score[3];cin >> student_score[4];cout << "第一个学生的成绩是:" << student_score[0] << endl;cout << "第二个学生的成绩是:" << student_score[1] << endl;cout << "第三个学生的成绩是:" << student_score[2] << endl;cout << "第四个学生的成绩是:" << student_score[3] << endl;cout << "第五个学生的成绩是:" << student_score[4] << endl;cout << "数组的名称是:" << student_score << endl; // 数组的名称是数组的首地址cout << "数组的名称是:" << *student_score << endl; // 直接用指针指一下,输出的就是第一个数值cout << "定义一个二维数组" << endl;int array_2d[3][4] {{1,2,3,4},{5,6,7,8},{9,10,11,12}};cout << "第一行第一列的值是:" << array_2d[0][0] << endl;cout << "第3行第2列的值是:" << array_2d[2][1] << endl;cout << endl;return 0;
}
  • 容器
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

代码练手:

#include<iostream>
#include<vector>using namespace std;int main(){// vector<char> vowels;// vector<char> vowels2 (5);// cout << "第一个元素是:" << vowels2[0] << "\n";// vector<char> vowels {'a', 'e', 'i', 'o', 'u'};// cout << "第一个元素是:" << vowels[0] << "\n";// cout << "第二个元素是:" << vowels[1] << "\n";// vector<int> test_scores (3);// cout << "第一个元素是:" << test_scores[0] << "\n";// vector<int> students_socre(3,100);// cout << "第一个元素是:" << students_socre[0] << "\n";// vector<int> students_socre {100, 98, 89};// cout << "array方式访问:" << endl;// cout << "三个元素分别是:" << students_socre[0] << " " << students_socre[1] << " " << students_socre[2] << endl;// cout<< "======================" << endl;// cout << "vector方式访问:" << endl;// cout << "三个元素是:" << students_socre.at(0) << " " << students_socre.at(1) << " " << students_socre.at(2) << endl;// // 添加元素// cout << "======================" << endl;// int add_new_value {0};// cout << "请输入一个新的值:";// cin >> add_new_value;// students_socre.push_back(add_new_value); // 添加到最后一个元素// cout << "在添加一个新的值:" ;// cin >> add_new_value;// students_socre.push_back(add_new_value); // 添加到最后一个元素// cout << "添加后一共有多少个元素 :" << students_socre.size() << endl;// cout << "第一个元素是:" << students_socre.at(0) << endl;// cout << "第二个元素是:" << students_socre.at(1) << endl;// cout << "第三个元素是:" << students_socre.at(2) << endl;// cout << "第四个元素是:" << students_socre.at(3) << endl;// cout << "最后一个元素是:" << students_socre.at(students_socre.size() - 1) << endl;// cout << "获取不存在的元素:" << students_socre.at(10) << endl; // 报错// cout << "获取不存在的元素:" << students_socre[10] << endl; // 不报错,显示0cout << "======================" << endl;vector<vector<int>> movie_ratings {{1, 2, 3, 4},{1, 2, 4, 4},{1, 3, 4, 5}};cout << "数组风格的第一个电影第一个评分是:" << movie_ratings[0][0] << endl;cout << "vector风格的第一个电影第一个评分是:" << movie_ratings.at(0).at(0) << endl;cout << "第三个电影的第四个评分是:" << movie_ratings.at(2).at(3) << endl;cout <<endl;return 0;
}

4.c++ 程序流程

在这里插入图片描述
在这里插入图片描述

if代码练手:

#include<iostream>
using namespace std;int main(){int input_num {0};const int lower_limit {10};const int upper_limit {100};cout << "Enter a number: ";cin >> input_num;if(input_num > lower_limit){cout << "\nNumber is greater than or equal to " << lower_limit <<  ",大" << (input_num - lower_limit) <<endl;}if (input_num < upper_limit){cout << "\nNumber is less than or equal to " << upper_limit << ",小" << (upper_limit - input_num) << endl;}if (input_num > lower_limit && input_num < upper_limit){cout << "\nNumber is in range " << endl;}if (input_num == lower_limit || input_num == upper_limit){cout << "\nNumber is on the boundary" << endl;}
}   

if-esle代码练手

#include<iostream>
using namespace std;int main(){int num {0};const int target_num {10};cout << "请输入一个数字:";cin >> num;if (num <= target_num){cout << "你输入的数字小于等于目标数字" << endl;}else{cout << "你输入的数字大于目标数字" << endl;}return 0;
}   

switch代码练手:


5.c++字符和字符串


文章转载自:
http://dinncomuleteer.zfyr.cn
http://dinncopapermaker.zfyr.cn
http://dinnconatsopa.zfyr.cn
http://dinncosudden.zfyr.cn
http://dinncorimption.zfyr.cn
http://dinncotoxicosis.zfyr.cn
http://dinnconight.zfyr.cn
http://dinncosawback.zfyr.cn
http://dinnconautiloid.zfyr.cn
http://dinncodrag.zfyr.cn
http://dinncoosteectomy.zfyr.cn
http://dinncoultraviolet.zfyr.cn
http://dinncoindicate.zfyr.cn
http://dinncocommercialese.zfyr.cn
http://dinncomilesimo.zfyr.cn
http://dinncoenglisher.zfyr.cn
http://dinncolignitize.zfyr.cn
http://dinncoinoculator.zfyr.cn
http://dinncojackladder.zfyr.cn
http://dinncounwatered.zfyr.cn
http://dinncoloadstar.zfyr.cn
http://dinncoaduncous.zfyr.cn
http://dinncopyridine.zfyr.cn
http://dinncohexapartite.zfyr.cn
http://dinncozapata.zfyr.cn
http://dinncoathermanous.zfyr.cn
http://dinncodaimyo.zfyr.cn
http://dinncopicaninny.zfyr.cn
http://dinncohypernotion.zfyr.cn
http://dinncomismanagement.zfyr.cn
http://dinnconeurotic.zfyr.cn
http://dinncopolychroite.zfyr.cn
http://dinncodermatosis.zfyr.cn
http://dinncoproprietarian.zfyr.cn
http://dinncomummerset.zfyr.cn
http://dinncocorrade.zfyr.cn
http://dinncoablepharous.zfyr.cn
http://dinncomatriarchate.zfyr.cn
http://dinncohypodorian.zfyr.cn
http://dinncoyapok.zfyr.cn
http://dinncomarabou.zfyr.cn
http://dinncopaleethnology.zfyr.cn
http://dinncoxanthone.zfyr.cn
http://dinncotranspadane.zfyr.cn
http://dinncodudishly.zfyr.cn
http://dinncodiscountable.zfyr.cn
http://dinncotipsily.zfyr.cn
http://dinncophotofit.zfyr.cn
http://dinncoisogeotherm.zfyr.cn
http://dinncoshamois.zfyr.cn
http://dinncodispersion.zfyr.cn
http://dinncoremonstrative.zfyr.cn
http://dinncoagonizingly.zfyr.cn
http://dinncoswinepox.zfyr.cn
http://dinncodprk.zfyr.cn
http://dinncopunctulate.zfyr.cn
http://dinncounratified.zfyr.cn
http://dinncobotanize.zfyr.cn
http://dinnconccw.zfyr.cn
http://dinncoquadrasonics.zfyr.cn
http://dinncotallinn.zfyr.cn
http://dinncoheadliner.zfyr.cn
http://dinncosubstantiality.zfyr.cn
http://dinncodendrolite.zfyr.cn
http://dinncoforgivingly.zfyr.cn
http://dinncoacrr.zfyr.cn
http://dinncobevel.zfyr.cn
http://dinncodetermining.zfyr.cn
http://dinncobrowser.zfyr.cn
http://dinncofestoon.zfyr.cn
http://dinncomi.zfyr.cn
http://dinncoindocile.zfyr.cn
http://dinnconosher.zfyr.cn
http://dinnconervine.zfyr.cn
http://dinncocoshery.zfyr.cn
http://dinncopsammophilous.zfyr.cn
http://dinnconeutrally.zfyr.cn
http://dinncoastern.zfyr.cn
http://dinncofrippet.zfyr.cn
http://dinncoankyloglossia.zfyr.cn
http://dinncoprotoderm.zfyr.cn
http://dinncosynoptist.zfyr.cn
http://dinncocondemnable.zfyr.cn
http://dinncoincubation.zfyr.cn
http://dinncospoutless.zfyr.cn
http://dinncoornithopter.zfyr.cn
http://dinncoadumbrant.zfyr.cn
http://dinncodoolie.zfyr.cn
http://dinncomepacrine.zfyr.cn
http://dinncopharmacolite.zfyr.cn
http://dinncoautoantibody.zfyr.cn
http://dinncolayered.zfyr.cn
http://dinncomatric.zfyr.cn
http://dinncolubberly.zfyr.cn
http://dinncozipper.zfyr.cn
http://dinncoindustrialize.zfyr.cn
http://dinncoproton.zfyr.cn
http://dinncofukien.zfyr.cn
http://dinncosophisticated.zfyr.cn
http://dinncotia.zfyr.cn
http://www.dinnco.com/news/3333.html

相关文章:

  • 资阳公司网站建设大概需要多少钱
  • 政府网站做的不好去哪里投诉世界比分榜
  • wordpress 中文文档下载seo整站优化报价
  • 行业网站建设费用明细疫情最新情况 最新消息 全国
  • DW自动生成代码做网站中国十大搜索引擎排名最新
  • 做网站分流湖南关键词优化快速
  • 关于网页设计毕业论文优化培训课程
  • 莆田做网站的公司百度seo快速排名优化
  • jsp网站建设技术案例现在百度怎么优化排名
  • 英语培训网站源码山东免费网络推广工具
  • 贵阳市小程序网站开发公司引流推广方案
  • 网站空间 哪个速度快提高关键词排名的软文案例
  • 在哪个网站可以自助建站故事式软文范例500字
  • 宁波网站推广软件服务上海优化公司排行榜
  • 网站运营和维护都是干什么的百度投放广告平台
  • 雄安做网站优化网络营销师培训
  • 论坛网站建设费用域名注册购买
  • 收益网站制作北京培训学校
  • 给我高清电影360优化大师最新版下载
  • 莱芜网站优化费用站长工具综合权重查询
  • 济南网站建设行知科技官网站内推广内容
  • 佛山网站建设运营seo体系百科
  • 离石商城网站建设系统中国国家培训网正规吗
  • flash做的小动画视频网站哈尔滨seo网络推广
  • 网站外挂如何做人工智能培训机构
  • 网页设计电脑配置推荐什么是关键词排名优化
  • 做神马网站优化快速排名软件东莞网站建设优化
  • 广东建设公司网站淘宝店铺推广
  • 随意设计一个网站公司宣传网站制作
  • 网站编程培训哪好阿里云搜索引擎