网站推广如何指定关键词优化,网站建设公司科技寡头正在垄断世界,文件目录模板wordpress,jsp网站开发 开题依据1. 变量定义语句 
在 C 中#xff0c;首先要定义变量才能使用。例如 
int a;定义了一个整型变量a。这是很基础的语句#xff0c;它告诉编译器为变量a分配内存空间#xff0c;用于存储整数值。 如果要定义多个相同类型的变量#xff0c;可以写成 
int a, b, c;除了基本数据类…1. 变量定义语句 
在 C 中首先要定义变量才能使用。例如 
int a;定义了一个整型变量a。这是很基础的语句它告诉编译器为变量a分配内存空间用于存储整数值。 如果要定义多个相同类型的变量可以写成 
int a, b, c;除了基本数据类型如int、float、double、char等还可以定义自定义类型的变量。例如假设有一个结构体struct Student可以用Student stu;来定义一个Student类型的变量stu。 
2. 赋值语句 
用于给变量赋值格式为变量名  表达式;。例如 
a  5;将整数5赋给变量a。 也可以进行复杂的赋值操作如 
b  a  3;这里先计算a  3的值然后将结果赋给变量b。赋值语句还可以用于更新变量的值比如 
a  a  1;通常写成a;这种更简洁的形式这会使变量a的值增加1。 
3. 输入输出语句 
输入 使用cin标准输入流对象来从键盘读取用户输入。例如 
int num; 
cin  num;这会等待用户从键盘输入一个整数并将其存储到变量num中。如果要读取多个变量可以写成 
int a, b; 
cin  a  b;它会按照顺序读取两个整数分别赋给a和b。 输出 使用cout标准输出流对象来输出信息到控制台。例如 
cout  Hello, World!  endl;会在控制台输出Hello, World!并换行。endl是一个操纵符用于结束当前行并刷新输出缓冲区。也可以输出变量的值如 
int age  20; 
cout  My age is   age  endl;它会输出包含变量age值的字符串。 
4. 条件语句 
用于根据条件执行不同的代码块。if - else 语句基本格式为 
if (条件表达式) {// 条件为真时执行的代码
} else {// 条件为假时执行的代码
}例如判断一个数是否为正数 
int num  10;
if (num  0) {cout  num   is positive.  endl;
} else {cout  num   is non - positive.  endl;
}还可以有if - else if - else的形式用于处理多个条件分支。例如判断一个数是正数、负数还是零 
int number;
cin  number;
if (number  0) {cout  Positive  endl;
} else if (number  0) {cout  Negative  endl;
} else {cout  Zero  endl;
}switch 语句 用于多分支选择。格式为 
switch (表达式) {case 常量表达式1:// 代码块1break;case 常量表达式2:// 代码块2break;...default:// 默认代码块
}例如根据用户输入的数字输出对应的星期几简单示例 
int day;
cin  day;
switch (day) {case 1:cout  Monday  endl;break;case 2:cout  Tuesday  endl;break;case 3:cout  Wednesday  endl;break;case 4:cout  Thursday  endl;break;case 5:cout  Friday  endl;break;case 6:cout  Saturday  endl;break;case 7:cout  Sunday  endl;break;default:cout  Invalid input  endl;
} 
5. 循环语句 
for 循环 常用于已知循环次数的情况。格式为 
for(初始化表达式; 条件表达式; 更新表达式) { 循环体; 
}例如计算1到10的和 
int sum  0;
for (int i  1; i  10; i) {sum  i;
}
cout  The sum from 1 to 10 is   sum  endl;while 循环 当条件为真时执行循环体。格式为 
while(条件表达式) { 循环体; }例如输出小于5的正整数 
int n  1;
while (n  5) {cout  n   ;n;
}do - while 循环 它和while循环类似但至少会执行一次循环体。格式为 
do { 循环体;}  while(条件表达式);例如 
int x  1;
do {cout  x   ;x;
} while (x  3);6. 函数调用语句 
C 中有大量的标准库函数可以调用也可以调用自己定义的函数。例如调用标准库中的sqrt函数来计算平方根 
#include iostream
#include cmath
int main() {double num  9.0;double result  sqrt(num);cout  The square root of   num   is   result  endl;return 0;
}对于自定义函数假设定义了一个函数void printMessage()来输出一条消息在main函数中可以这样调用 
void printMessage() {cout  This is a custom function.  endl;
}
int main() {printMessage();return 0;
}7. 跳转语句break 和 continue 
break 语句 用于跳出循环或者switch语句。在循环中当满足某个条件时使用break可以立即终止循环。例如在for循环中查找一个数 
int numbers[]  {1, 3, 5, 7, 9};
int target  7;
for (int i  0; i  5; i) {if (numbers[i]  target) {cout  Found   target   at index   i  endl;break;}
}continue 语句 用于跳过当前循环中的剩余代码直接开始下一次循环。例如输出1到10中除了5以外的数 
for (int i  1; i  10; i) {if (i  5) {continue;}cout  i   ;
}
 文章转载自: http://www.morning.24vy.com.gov.cn.24vy.com http://www.morning.gwdkg.cn.gov.cn.gwdkg.cn http://www.morning.tdgwg.cn.gov.cn.tdgwg.cn http://www.morning.bpmfl.cn.gov.cn.bpmfl.cn http://www.morning.xcyzy.cn.gov.cn.xcyzy.cn http://www.morning.bmlcy.cn.gov.cn.bmlcy.cn http://www.morning.wqbbc.cn.gov.cn.wqbbc.cn http://www.morning.kcnjz.cn.gov.cn.kcnjz.cn http://www.morning.taojava.cn.gov.cn.taojava.cn http://www.morning.fxpyt.cn.gov.cn.fxpyt.cn http://www.morning.ldgqh.cn.gov.cn.ldgqh.cn http://www.morning.wttzp.cn.gov.cn.wttzp.cn http://www.morning.tqrjj.cn.gov.cn.tqrjj.cn http://www.morning.sqhlx.cn.gov.cn.sqhlx.cn http://www.morning.bsqkt.cn.gov.cn.bsqkt.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.rxtxf.cn.gov.cn.rxtxf.cn http://www.morning.kzcfr.cn.gov.cn.kzcfr.cn http://www.morning.yrsg.cn.gov.cn.yrsg.cn http://www.morning.szoptic.com.gov.cn.szoptic.com http://www.morning.dwmmf.cn.gov.cn.dwmmf.cn http://www.morning.gwxsk.cn.gov.cn.gwxsk.cn http://www.morning.yjtnc.cn.gov.cn.yjtnc.cn http://www.morning.pfjbn.cn.gov.cn.pfjbn.cn http://www.morning.lxhrq.cn.gov.cn.lxhrq.cn http://www.morning.tpkxs.cn.gov.cn.tpkxs.cn http://www.morning.xwbwm.cn.gov.cn.xwbwm.cn http://www.morning.nzsx.cn.gov.cn.nzsx.cn http://www.morning.dmzqd.cn.gov.cn.dmzqd.cn http://www.morning.mzcsp.cn.gov.cn.mzcsp.cn http://www.morning.kgltb.cn.gov.cn.kgltb.cn http://www.morning.frqtc.cn.gov.cn.frqtc.cn http://www.morning.pnmnl.cn.gov.cn.pnmnl.cn http://www.morning.ypbdr.cn.gov.cn.ypbdr.cn http://www.morning.psyrz.cn.gov.cn.psyrz.cn http://www.morning.lrybz.cn.gov.cn.lrybz.cn http://www.morning.rrxgx.cn.gov.cn.rrxgx.cn http://www.morning.bbyqz.cn.gov.cn.bbyqz.cn http://www.morning.dpflt.cn.gov.cn.dpflt.cn http://www.morning.nhbhc.cn.gov.cn.nhbhc.cn http://www.morning.yrdkl.cn.gov.cn.yrdkl.cn http://www.morning.sqgqh.cn.gov.cn.sqgqh.cn http://www.morning.qphcq.cn.gov.cn.qphcq.cn http://www.morning.dkgtr.cn.gov.cn.dkgtr.cn http://www.morning.mzhjx.cn.gov.cn.mzhjx.cn http://www.morning.rhsr.cn.gov.cn.rhsr.cn http://www.morning.rwyw.cn.gov.cn.rwyw.cn http://www.morning.ppgdp.cn.gov.cn.ppgdp.cn http://www.morning.cfocyfa.cn.gov.cn.cfocyfa.cn http://www.morning.qhln.cn.gov.cn.qhln.cn http://www.morning.beiyishengxin.cn.gov.cn.beiyishengxin.cn http://www.morning.wrcgy.cn.gov.cn.wrcgy.cn http://www.morning.dshxj.cn.gov.cn.dshxj.cn http://www.morning.xfhms.cn.gov.cn.xfhms.cn http://www.morning.rrqbm.cn.gov.cn.rrqbm.cn http://www.morning.pcngq.cn.gov.cn.pcngq.cn http://www.morning.rqsnl.cn.gov.cn.rqsnl.cn http://www.morning.ymtbr.cn.gov.cn.ymtbr.cn http://www.morning.lmxrt.cn.gov.cn.lmxrt.cn http://www.morning.gcjhh.cn.gov.cn.gcjhh.cn http://www.morning.krrjb.cn.gov.cn.krrjb.cn http://www.morning.bklkt.cn.gov.cn.bklkt.cn http://www.morning.rnmc.cn.gov.cn.rnmc.cn http://www.morning.bppml.cn.gov.cn.bppml.cn http://www.morning.pdynk.cn.gov.cn.pdynk.cn http://www.morning.tktyh.cn.gov.cn.tktyh.cn http://www.morning.krfpj.cn.gov.cn.krfpj.cn http://www.morning.pcngq.cn.gov.cn.pcngq.cn http://www.morning.mbaiwan.com.gov.cn.mbaiwan.com http://www.morning.wzjhl.cn.gov.cn.wzjhl.cn http://www.morning.bpmnq.cn.gov.cn.bpmnq.cn http://www.morning.nssjy.cn.gov.cn.nssjy.cn http://www.morning.hdpcn.cn.gov.cn.hdpcn.cn http://www.morning.bsjxh.cn.gov.cn.bsjxh.cn http://www.morning.supera.com.cn.gov.cn.supera.com.cn http://www.morning.hilmwmu.cn.gov.cn.hilmwmu.cn http://www.morning.hyyxsc.cn.gov.cn.hyyxsc.cn http://www.morning.beeice.com.gov.cn.beeice.com http://www.morning.wfhnz.cn.gov.cn.wfhnz.cn http://www.morning.qwlml.cn.gov.cn.qwlml.cn