#include <malloc.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int is_prime(int n){
int m
for(m=2 m <= (int)sqrt(n) m++){
if(n%m == 0){
return 0
}
}
return 1
}
void timu_1(){
int min = 500
int max = 1000
int sum = 0
int i
for(i = min i <= max i++){
if(is_prime(i)){
sum = sum + i
}
}
printf("the sum of prime numbers between %d - %d is %d \n" , min , max , sum)
}
void timu_2(){
int count = 20
int i
float sum = 0.0
float a = 2.0
float b = 1.0
float c = 0.0
for(i = 0 i < count i++){
sum += a / b
//printf("%d 枣郑%f/%f\n" , i , a , b)
c = a
a = a + b
b = c
}
printf("the sum is %f \n" , sum)
}
void timu_3(){
float sum = 0.0
int min = 1000
int max = 2000
int count = 0
int i
for(i = min i <= max i++){
if(is_prime(i)){
sum += i
count++
}
}
printf("prime numbers average between %d - %d is %.2f\n" , min , max , sum/count)
}
void timu_4(){
int ary[] = {56,78,98,45,58,34,12,90,26,88}
int i , j , len
int count = 3
float sum = 0.0
for(i = 0 , len = sizeof(ary)/sizeof(int) i < len i++){
for(j = i+1 j < len j++){
if(ary[j]>ary[i]){
ary[j] = ary[i] ^ ary[j]
ary[i] = ary[i] ^ ary[j]
ary[j] = ary[i] ^ ary[j]
}
}
}
for(i = 0 i < count i++){
sum += sqrt(ary[i])
}
printf(" %f \n" , sum) 档岩漏
}
void timu_5(){
int sum = 0
int i = 1
do{
sum += (2*i-1)*(2*i+1)
if(((sum%7)==0) && (sum > 1000)){
printf("sum : %d n=%d\n" , sum , i)
break
}
i++
}while(1)
}
void timu_6(){
static int ary[20] = { 1 }
int i, j
int width /*---表示结果的"宽度"---*/
int current_num /*--- 当前数字 ---*/
/*--- 从大到小进行阶乘计算 ---*/
for( width = 0 , current_num = 20 current_num > 1 current_num-- ){
/*--- 对每一个‘分段’进行运算 ---*/
for( i = j = 0 i 行烂<= width i++ ){
/*--- 当前运算的‘有效数值’ ---*/
ary[i] = ( (j += ary[i] * current_num) ) % 10000
/*--- 当前运算的‘进位数值’ ---*/
j /= 10000
}
if ( ary[i] = j ){ /*如果有进位,则索引向前推进*/
width++
}
}
printf ( "%d", ary[width] )
/*--- 将求的数值输出 ---*/
for( j = width - 1 j >= 0 j-- ){
printf( "%04d", ary[j] )/*--- 这里的6跟10000的位数有关 ---*/
}
printf("\n")
}
void timu_7(){
srand(time(NULL))
int len = 10
int* ary = (int* )malloc(sizeof(int)*len)
if(ary == NULL){
printf("malloc error !\n")
exit(1)
}
int sum = 0
int num , i
float ave = 0.0
int count = 0
for(i = 0 i < len i++){
num = (rand()%90)+10
*(ary+i) = num
sum += num
}
ave = 1.0*(sum/len)
for(i = 0 i < len i++){
if(*(ary+i) < ave){
count++
}
printf("ary[%d]=%d " , i , *(ary+i))
}
printf("average=%.1f\n" , ave)
int* out = (int*)malloc(sizeof(int)*count)
if(out == NULL){
printf("malloc error !\n")
exit(1)
}
int j
for(i = 0 , j = 0 i < len i++){
if(*(ary+i) < ave){
*(out+j)=*(ary+i)
printf("ary[%d]=%d " , j , *(out+j))
j++
}
}
printf("\n")
for(i = 0 i < count i++){
printf("out[%d]=%d " , i , *(out+i))
}
free(ary)
free(out)
printf("\n")
}
void timu_8(){
int n
int max
for(n = 1 , max = (2*n-1)*(2*n) max < 10000 n++){
max = (2*n-1)*(2*n)*max
}
printf("%d\n" , n)
}
void timu_9(){
int min = 300
int max = 500
int sum = 0
int i
for(i = min i <= max i++){
if((i%5)==0 && (i%7)==0){
printf("[%d]" , i)
sum += i
}
}
printf(" sum = %d\n" , sum)
}
int gy(int a , int b){
int r
while(r = a%b){
a = b
b = r
}
return b
}
void timu_10(){
printf("%d | " , gy(2352 , 3696))
}
void timu_11(){
int count = 15
srand(time(NULL))
int* ary = (int*)malloc(sizeof(int)*count)
if(ary == NULL){
printf("malloc error!\n")
exit(1)
}
int i
for(i = 0 i < count i++){
*(ary+i) = (rand() % 89) + 10
}
for(i = 0 i < count i++){
printf("ary[%d]=%d " , i , *(ary+i))
}
int j
for(i = 0 i < count i++){
for(j=i+1 j < count j++){
if(*(ary+i) < *(ary+j)){
*(ary+i) = *(ary+i) ^ *(ary+j)
*(ary+j) = *(ary+i) ^ *(ary+j)
*(ary+i) = *(ary+i) ^ *(ary+j)
}
}
}
printf("\nsort:\n")
for(i = 0 i < count i++){
printf("ary[%d]=%d " , i , *(ary+i))
}
free(ary)
}
void echo_t(int i){
printf("\n%-4d:----------------------------:^^^:\n" , i)
}
int main(int argc , char ** argv){
echo_t(1)timu_1()
echo_t(2)timu_2()
echo_t(3)timu_3()
echo_t(4)timu_4()
echo_t(5)timu_5()
echo_t(6)timu_6()
echo_t(7)timu_7()
echo_t(8)timu_8()
echo_t(9)timu_9()
echo_t(10)timu_10()
echo_t(11)timu_11()
return 0
}
1602液晶显示 的超声波蔽枯仔模块程序 接口程序里边宏汪都有、、 #include //#include #include #define uchar unsigned char #define uint unsigned int sbit lcdrs=P2^3sbit lcden=P2^2sbit trig=P2^0//超声波发送 //sbit echo=P3^2//超声波接受败亏...用于电力、通信、铁路及工矿企业等部门各种装置接地电阻值的测量,也适用于测量回路电阻。GY-316高压铁塔接地电阻测试仪
1、大钳口设计适用于各种形状的接地线.
2、非接触式测量接地电阻,安全快速.
3、在线测试,不须中断待测设备之接地.
4、抗干扰罩闭运能力强,自产生高频电流从而过滤市电中50Hz 100Hz等谐波干扰电流,测量准确度高.
5、配置充电电池和充电器,省电态余设计,超过规定时间自动断电,电池极限报警功能.
技术参数
1、测量范围:0.01~100Ω
2、最小分辨率:0.01Ω
3、工作温度:0°C~40°C
5、电源:4节5号镍氢充电电池
6、重量:0.8kg(不含附件)
物梁7、尺寸:230x120x42mm
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)