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

基于js原生的新闻类静态网站建设正版google下载

基于js原生的新闻类静态网站建设,正版google下载,群晖 wordpress 性能,哈尔滨建站人1、什么是数组 数组,就是多个元素的有序“组合”。 C 和 C语言中的数组: 1 )由多个大小相同的小柜子组成 > 相同大小的内存块组成,即相同类型的数据 2 )这些小柜子,有自己对应的编号 > 编号从 …

1、什么是数组

数组,就是多个元素的有序“组合”。
C 和 C++语言中的数组:
1 )由多个大小相同的小柜子组成 => 相同大小的内存块组成,即相同类型的数据
2 )这些小柜子,有自己对应的编号 => 编号从 0 开始递增
3 )而且这些编号是递增顺序。
数组的“容量”是不能改变的。
学过数据结构的都知道,数组有静态分配和动 态分配,动态分配可以改变容量。

 数组的定义

数组和其他变量一样,需要先定义,再使用。
实例:
int a[8];
// 定义了一个数组,
// 数组名是“a”,
// 包含 8 个元素,
// 每个元素是 int 类型的变量
a[0] = 20;
a[1] = 5;
说明:
定义了如下数组:
int a[8];
就相当于定义了 8 int 类型的变量
而且这 8 个变量是连续存储在内存中的。(8 个依次相连的邻居)
实例:
某渣男,想要记录他 10 个女友的身高,可以定义如下:
float girlFirends[8];
girlFirends[5] = 1.78;
int ages[50];
ages[0] = 18;
ages[49] = 19;
数组的初始化
在定义数组的同时,设置数组内的元素值。
int a[8] = {20, 5, 30, 13, 18};
printf("%d,%d,%d,%d,%d\n", a[0],a[1],a[2],a[3],a[4]);
或者
cout << a[0] << “,” << a[1] << “,” << a[2] << “,” << a[3] << “,” << a[4];
int a[8] = {0}; //把数组的所有元素都初始化为 0
printf("%d,%d,%d,%d,%d\n", a[0],a[1],a[2],a[3],a[4]);// 这种方式你得清楚是所有元素都置为0
int a[8] = {1}; // 把 a[0]初始化为 1,其它值都初始化为 0
int b[8] = {1, 5}; // 把 a[0]初始化为 1,a[1]初始化为 5,其它值都初始化为 0,不要以为后面的元素是其它值哦!!
int a[] = {1,2,5}; // 定义数组 a, 这个数组包含 3 个元素!
// 根据“初始化列表”,自动计算数组的容量
高逼格用法(在某些特殊场合使用)
优点:但数组的成员较多时,该方式可读性高
缺点:仅仅 C 编译器支持, C++ 编译器中不支持,即 C++ 程序中不能使用。
// 每周的锻炼时间:
int exercises[7] = {
[1] = 1, //a[1] = 1
[3] = 2, //a[3] = 2
// 没有指定的成员,被初始化为 0
};
不是连续方式赋值,只有C 编译器支持, c++ 编译器不支持这种方式,不建议这样使用,但是要知道这种赋值方式,以后开发不建议用这种赋值方式。
常见错误
int a[2] = {1,2,5}; //错误!初始值太多,大于数组的容量
int a[3];
a = {1, 2, 3}; //不能对数组名直接赋值!
int a[3];
a[3] = 10; //下标越界!下标的取值范围是 0, 1, 2

 数组元素的访问

通过下标访问对应的元素。

特别注意, 数组的第一个元素的下标是 0, 而不是 1
int girlSize[10];
a[5] = 38;
printf(“%d\n”, a[5]);
cout << a[5];
另类用法:
使用下标的方式访问 string 字符串
string name = "Rock";
//name[i]是 string 字符串中的第 i 个字符(char 类型)
for (int i=0; i< name.length(); i++) {
cout << name[i];
}
name[0] = 'L'; //name 变成:Lock
cout << endl << name;
name 虽然不是数组,但是可以通过数组的形式来访问字符串。重点哦!

数组的越界
数组的越界, 是指下标超出正常的范围!
例如:
int a[10]; //a[-1] a[10] 都是越界!
越界的后果
越界非常危险,可能导致数据破坏,或其他不可预期的后果!
越界的控制
需要程序员自己手动控制,编译器不做任何检查!因为, C/C++ 语言完全信任程序员!

2、C 风格的字符串详解

C 语言字符串的存储、初始化
字符串,是通过“字符数组” ( 元素类型为 char 的数组)来存储的!
demo1

char name[10];
name[0] = 'R';
name[1] = 'o';
name[2] = 'c';
name[3] = 'k';
name[4] = 0; //字符串结束符 0,就是 '\0'
printf(" 姓名: %s", name); //姓名: Rock
name[2] = 0;
printf(" 姓名: %s", name); //姓名:Ro

 demo2

char name[10] = "Rock"; // 相当于 char name[10] = {'R', 'o', 'c', 'k', ' \0 '};
printf(" 姓名: %s", name);

 demo3

char name[] = "Rock"; //相当于:name[5] = "Rock"

printf("%d", sizeof(name)); //5

C 语言字符串的输入输出 

#include <stdio.h>
#include <Windows.h>
int main( void ) {
char name[16];
char addr[64];
printf( " 姑娘芳名 ?\n" );
scanf( "%s" , name);
// 此时输入缓冲区中还有一个回车符
// 清空输入缓冲区
fflush(stdin);// 有些编译器不支持这个用法
printf( " 姑娘家住何地 ?\n" );
gets(addr); // 读一行,包括一行中的空格
printf( " 家住 %s %s, 我中意你 !\n" , addr, name);
system( "pause" );
return 0;
}

 3、计算机英语加油站

string
字符串
length
长度
scanf
C 语言的标准输入函数
parameter
参数
return value
返回值
str on success, NULL on failure.
如果成功,就是 str
如果失败,就是 NULL

4、常见错误总结

错误 1
cin.sync() VS 中失效 !
C++ 的标准中 , cin.sync() 是清空缓冲区 , 但是实际的实现取决于编译器.
如果使用 vc++ 或者 g++ 编译器 , 是可以的 , 但是使用 vs 中的编译器 , 就不可以 .
使用自定义的 clearBuff();
#include <iostream>
#include <Windows.h>
#include <stdio.h>
using namespace std;
void clearBuff() {
char tmp;
while ((tmp = getchar()) != '\n' );
}
int main( void ) {
int age = 0;
int height =
0;
//身高, 单位:cm
cout << "请输入年龄: " << endl;
cin >> age;

if (cin.fail()) {
cout << "输入失败,应该输入一个整数" << endl;
cin.clear();
//cin.sync();
clearBuff();
}
cout << "请输入身高: " << endl;
cin >> height;
cout << "年龄: " << age << endl;
cout << "身高:" << height << endl;
system( "pause" );
return 0;
}
cin.sync() VS 编译器中失效,VS 编译器不支持这种用法,但不能说VS编译器不好。它是公认最好的开发平台。

错误 2
int a[3];
a = {1, 2, 3}; //错误
a[3] = 100;
错误 3
string s;
s = 3.14 * 100 * 100;//赋值的数据类型和定义的变量的类型不一致
int name[32];
scanf(“%s”, name);//整数不能用字符串的格式输入
注意:
string c++ 特有的一种数据类型,不能用C 语言的 scanf 来输入数据。会出现编译器警告。

5、职场修炼:技术和领导关系哪个更重要

1. IT 研发职场中,不要过分依赖领导关系。
2. 要与领导保持积极主动的沟通关系,闷头苦干会丢失很多机会。
3. 技术上,要尽快掌握公司的核心开发业务。
补充:一切关系,都是以个人的价值为基础的。

 6、逼格提升:解决 Bug 的第 1 手段-断点调试

问题代码:
#include <iostream>
#include <Windows.h>
#include <string.h>
using namespace std;

int main(void)

{
float r;
float s;
cout << " 请输入圆的半径: " ;
scanf( "%f" , r);
s = 3.14 * r * r;
cout << " 面积是: " << s << endl;
system( "pause" );
return 0;
}

你发现问题所在的地方了吗??答案(缺少地址符&) 

练习1:

连续读入多个单词,然后统计这些单词的总的长度、以及单词个数。 直到输入结束: (按下 Ctrl +z, 就会输入一个特殊的字符:文件结束符 EOF ) ,分别使用 C C++ 实现。
C++ 版本
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
int main( void ) {
string word;
int count = 0;
int length = 0;
cout << " 请输入任意多个单词: " ;
while (1) {
// 输入成功时,返回 cin 对象本身
// 遇到文件结束符(
ctrl+z ),而导致输入失败是,返回 0
if ((cin >> word) == 0) {
break ;
}
count++;
length += word.length();
}
cout << " 一共有 " << count << " 单词 " << endl;
cout << " 总长度: " << length << endl;

system( "pause" );
return 0;
}

 C 语言版本

#include <stdio.h>
#include <string.h>
#include <Windows.h>
int main( void ) {
char word[64];
int count = 0;
int length = 0;
printf( " 请输入任意多个单词: " );
while (1) {
// 输入失败 返回 0
// 遇到文件结束符 (
ctrl+z ),返回 -1 EOF
if (scanf( "%s" , word) == -1) {
break ;
}
count++;
length += strlen(word);
}
printf( " 一共有 %d 个单词 \n" , count);
printf( " 总长度: %d\n" , length);
system( "pause" );
return 0;
}
练习 2
连续输入多行字符串(文本),统计中的行数,以及字符个数。
分别使用 C C++ 实现

 C 语言版本:

#include <stdio.h>
#include <string.h>
#include <Windows.h>
int main( void ) {
char line[2048];
int lineCount = 0;
int length = 0;
printf( " 请输入任意多行: " );

while (1) {
if ( gets(line) == 0) {
break ;
}
lineCount++;
length += strlen(line);
}
printf( " 一共有 %d \n" , lineCount);
printf( " 总长度: %d\n" , length);
system( "pause" );
return 0;
}

C++版本:

#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
int main( void ) {
string line;
int lineCount = 0;
int length = 0;
cout << " 请输入任意多行: " ;
while (1) {
// 遇到文件结束符时, 返回 NULL 0
if (getline(cin, line) == 0) {
break ;
}
lineCount++;
length += line.length();
}
cout << " 一共有 " << lineCount << " " << endl;
cout << " 总长度 : " << length << endl;
system( "pause" );
return 0;
}


文章转载自:
http://petrol.jftL.cn
http://inkhorn.jftL.cn
http://nonentanglement.jftL.cn
http://adulterine.jftL.cn
http://salon.jftL.cn
http://drumfish.jftL.cn
http://residuum.jftL.cn
http://extracondensed.jftL.cn
http://orangeade.jftL.cn
http://octopush.jftL.cn
http://sleeper.jftL.cn
http://medullary.jftL.cn
http://engrail.jftL.cn
http://corps.jftL.cn
http://calpack.jftL.cn
http://scrapper.jftL.cn
http://flurazepam.jftL.cn
http://communicative.jftL.cn
http://fierce.jftL.cn
http://assuringly.jftL.cn
http://intrusive.jftL.cn
http://initializers.jftL.cn
http://panicle.jftL.cn
http://butylene.jftL.cn
http://tallyho.jftL.cn
http://vaticanologist.jftL.cn
http://churlish.jftL.cn
http://submarginal.jftL.cn
http://zoned.jftL.cn
http://malefic.jftL.cn
http://minamata.jftL.cn
http://tbsp.jftL.cn
http://recloser.jftL.cn
http://arriviste.jftL.cn
http://bobsled.jftL.cn
http://ototoxic.jftL.cn
http://pooja.jftL.cn
http://revivor.jftL.cn
http://populism.jftL.cn
http://zymurgy.jftL.cn
http://lavash.jftL.cn
http://slavonic.jftL.cn
http://flaneur.jftL.cn
http://weathering.jftL.cn
http://myelination.jftL.cn
http://clutch.jftL.cn
http://enthalpy.jftL.cn
http://dissident.jftL.cn
http://midsplit.jftL.cn
http://concretively.jftL.cn
http://pronograde.jftL.cn
http://embayment.jftL.cn
http://simuland.jftL.cn
http://autoalarm.jftL.cn
http://refugee.jftL.cn
http://sprite.jftL.cn
http://skerrick.jftL.cn
http://joppa.jftL.cn
http://libbie.jftL.cn
http://chez.jftL.cn
http://choreopoem.jftL.cn
http://reassign.jftL.cn
http://wharfage.jftL.cn
http://leonis.jftL.cn
http://megalopolis.jftL.cn
http://soldierly.jftL.cn
http://injunction.jftL.cn
http://sparerib.jftL.cn
http://machiavel.jftL.cn
http://tempera.jftL.cn
http://vitreous.jftL.cn
http://bridgeboard.jftL.cn
http://smartness.jftL.cn
http://prolotherapy.jftL.cn
http://nucleation.jftL.cn
http://outdid.jftL.cn
http://slavery.jftL.cn
http://fumagillin.jftL.cn
http://basement.jftL.cn
http://retrofocus.jftL.cn
http://penetrability.jftL.cn
http://skirting.jftL.cn
http://peasecod.jftL.cn
http://trochilics.jftL.cn
http://col.jftL.cn
http://debus.jftL.cn
http://every.jftL.cn
http://rectorial.jftL.cn
http://bilharziasis.jftL.cn
http://overlong.jftL.cn
http://hokonui.jftL.cn
http://yuletime.jftL.cn
http://wysiwyg.jftL.cn
http://townsville.jftL.cn
http://cemetery.jftL.cn
http://occidentalise.jftL.cn
http://fonduta.jftL.cn
http://lossmaking.jftL.cn
http://shicker.jftL.cn
http://invasive.jftL.cn
http://www.dt0577.cn/news/79256.html

相关文章:

  • 网站建设销售销售流程地推
  • 河南省城乡和住房建设厅网站首页企业seo外包公司
  • 建设培训网站建设百度关键词搜索排名
  • 银川网站开发公司下店拓客团队
  • 怎么建设自己网站广告投放这个工作难不难做
  • 做微信商城网站公司百度官网首页官网
  • ps如何做psd模板下载网站南通seo网站优化软件
  • 国防教育网站建设说明书衡阳百度推广
  • 自己搭建个人网站的注意事项百度网盘搜索引擎入口官网
  • 郑州网站开发seo经理招聘
  • wordpress做网站手机考研最靠谱的培训机构
  • 建设网站赚广告费是否可行百度推广没有效果怎么办
  • 网站备案现场郴州seo快速排名
  • wordpress外链图片本地大连谷歌seo
  • 创可贴网页设计网站网站外链发布平台
  • 顺德大良网站建设开发seo服务外包报价
  • 江西网站建设公司竞价推广论坛
  • 一个电商网站开发需要多久百度网盘app怎么打开链接
  • 所见即所得网页编辑器seo门户网价格是多少钱
  • 中山织树网站建设高级搜索指令
  • 建设企业人力资源网站观看b站的广告网站平台
  • 长沙网站建设公司教育培训机构管理系统
  • 网站建设公司报价表全国疫情最新情况
  • 做直播网站需要学什么软件有哪些网络营销工资一般多少
  • 织梦网站文章发布模板下载整站优化seo公司哪家好
  • 深圳设计公司排名一百郑州百度关键词seo
  • 广州网站建设c2c网推资源渠道
  • 番禺区移动端网站制作知名的网络推广
  • 济南品牌网站建设价格搜索引擎优化实训
  • 网站版式类型网站搭建需要什么技术