c- language- learning 05操作符1

Sunday,27th,feb,2022

//操作符

//算术操作符:+ - * / %

//移位操作符:>>右移操作符,<<左移操作符

int a =9/2;

printf("%d\n",a); //4

float a =9/2;//除号两边都是整数时,得到的为整数商,而不是4.5

printf("%f\n",a); //4.000000

float a =9/2.0;//除号一边是小数时,得到的为4.5

printf("%f\n",a); //4.500000

int a =9%2;//取余

printf("%d\n",a); //1

int a =2;

int b = a<<1; //左移操作符,移动的是二进制位,

此时a是整型为4字节,

即32位的十进制2:0000 0000 0000 0000 0000 0000 0000 0010

a向左移1位:左滚:0000 0000 0000 0000 0000 0000 0000 00100 左移补零

移动后为4

printf("%d\n",b); //4

//位操作符:&(按位与) |(按位或)^(按位异或)

//赋值操作符

 //单目操作符

 

//!:用于判断真假

int main()

{

//c语言中规定:0表示假,非0就是真

int a=0;

printf(%d\n",!a); // 1

if(a

{

//如果a为真,做事

}

if(!a)

{

//如果a为假,做事

}

return 0;

}

//sizeof计算变量大小

此时int 和a 互值 sizeof一样的

 //sizeof不是函数,后面的括号求变量可以省略,求类型不能省略

printf("%d\n", sizeof (int));

printf("%d\n",sizeof a);

//sizeof计算一个数组大小(元素个数)

int main()

{

//10*4=40

int arr[10]={0};

printf("%d\n",sizeof(arr)); //40,计算的是数组的总字节,sizeof计算的是单位是字节

printf("%d\n",sizeof(arr[0])); //4

int se =sizeof(arr)/sizeof(arr[0]);

printf("%d\n",se);//10,通过数组总字节和一个元素字节求数组元素个数(大小)

return 0;

}

//~按位取反(区别假变成真,是用!)

int main()

{

 int a =0;

printf("%d\n",~a);

return 0;

}

~按(二进制)位取法

 内存中存储的是补码,打印的是原码

按位取反,包括符号位也要变

a为0正数,内存中所存的补码为全0,按位取反得全1补码,全1补码的真值为-1

//++

int main()

{

int a = 10;

int b = ++a; //前置++,先++,后使用

printf("%d\n", b); //11

printf("%d\n", a); //11

int a = 10;

int b = a++; //后置++,先使用,后++

printf("%d\n", b); //10

printf("%d\n", a); //11

return 0;

}

//(类型)强制类型转换

int a =(int)3.14;

printf("%d\n" , a);

否则丢失精度,3.14到int

 

//关系操作符

//逻辑操作符 (真假问题,是否)

c语言中0位假,1为真

 

c为int,正确的,为1 

a,b都为假,那么c或关系为假 ,为0

//条件操作符(三目操作符)

?:   三个操作数exp

 

 int main()

{

int a = 0;

int b =3;

int max =0;

/*if (a>b)

max =a;

else

max=b;

*/

max=a>b?a:b;

printf("%d\n",max);

return 0;

}

//逗号表达式

逗号隔开的一串表达式

 //下标引用、函数调用和结构成员

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Multi-objective evolutionary federated learning (MEFL) is a machine learning approach that combines the principles of multi-objective optimization and federated learning. Multi-objective optimization is a technique that aims to optimize multiple objectives simultaneously, while federated learning is a decentralized machine learning approach that allows multiple devices to train a model collaboratively without sharing their data. MEFL is designed to overcome the limitations of traditional federated learning approaches, which often suffer from issues related to privacy, communication, and scalability. By using multi-objective optimization, MEFL can optimize the performance of the federated learning algorithm while also addressing these issues. MEFL works by dividing the optimization problem into multiple objectives, such as minimizing the loss function, reducing communication costs, and preserving privacy. A genetic algorithm is then used to optimize these objectives simultaneously, producing a set of Pareto-optimal solutions that represent the trade-offs between the different objectives. These Pareto-optimal solutions can then be used to select the best model for deployment, depending on the specific requirements of the application. MEFL has been shown to be effective in a wide range of applications, including image classification, natural language processing, and speech recognition. Overall, MEFL represents a promising approach to federated learning that can improve the privacy, communication, and scalability of the algorithm while also optimizing its performance.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值