1.do while

It usually use on some specifc things such as count the digit of 0.

2.break

In switch,break can distinguish different case in case of codes chaos.

In circle,break can skip circle to last code while continue just can skip this circle to the last judge circle condition.

3.the circle nesting 

for example ,find prime.

#include<stdio.h>

int main()

{

int a = 0;

for(a = 101;a<201;a += 2)

{
int b = 0;

flag =1;

for(b = 2;b<a - 1;b++)

{
if(a % b == 0)

{
flag = 0 ;

break;
}
}

if(flat  == 1)

{
printf("%d ",a);

}
}

return 0;
}

4.goto

For example , using in some circle nestings or running again some codes.

5.rand ,srand,time three functions

Rand can generate stochastic number but this is false stochastic which controled by seed that presented by srand.So it is essential to use a transformable digital for srand to make sure 

rand transformable.And the parameter of srand is seed.

To be frank,we should put time(NULL which can put the current time) which can return current time in the parameter of srand to help it sending seed for rand to create a

different number.

6.A easy but helpful technique.

When we want to control a range of changing number(a~b),we can  use rand()%(b - a + 1). 

 
 

Logo

码道开发者社区,聚焦华为云码道 CodeArts 代码智能体,沉淀 Agent、Skill、鸿蒙开发实战内容,供开发者查阅资料、交流技术、分享工程实践

更多推荐