如何使用表达式为变量赋值?用C语言 [英] How to assign a value to a variable by using expression? In C language

查看:116
本文介绍了如何使用表达式为变量赋值?用C语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用表达式为变量赋值?用C语言

找到没有除法或三元运算符的两个nos的平均值



int a = 10,b = 20;

int avg =< expression> ;;

printf(%d,avg);



我尝试了什么:



我不知道



如何分配值通过使用表达式来变量?用C语言

找到没有除法或三元运算符的两个nos的平均值



int a = 10,b = 20;

int avg =< expression> ;;

printf(%d,avg);

How to assign a value to a variable by using expression? in C language
Find average of the two nos without division or ternary operator

int a=10,b=20;
int avg=<expression>;
printf("%d",avg);

What I have tried:

I have no Idea

How to assign a value to a variable by using expression? in C language
Find average of the two nos without division or ternary operator

int a=10,b=20;
int avg=<expression>;
printf("%d",avg);

推荐答案

会员13100982



您是否可以使用位操作?以下是最简单的解决方案:



int a = 10,b = 20;

int avg =(a + b)> > 1;

printf(%d,avg);



算法 - 没有除法的快速平均值 - 堆栈溢出 [ ^ ]


想想你的问题:

你需要知道什么是一半的东西,一种方式是除以2,还有另一种方式,它是数学。



我们不做你的家庭作业。
Think about your problem:
you need to know what is the half of something, one way is to divide by 2, there is another way, it is mathematics.

We do not do your HomeWork.


这篇关于如何使用表达式为变量赋值?用C语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆