奇怪的“+ =”行为(Strange “+=” behaviour)
此代码段必须返回什么? 16 16 16是吗?
int main(int argc,char *argv[]) { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f1+=a+=2.5; printf("%d %d %d\n",a,*f1,*f2); return 0; }
奇怪的是,它返回8 8 8给我? :-(
What must this code segment return ? 16 16 16 right ?
int main(int argc,char *argv[]) { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f1+=a+=2.5; printf("%d %d %d\n",a,*f1,*f2); return 0; }
strangely, it returns 8 8 8 to me ???? :-(
原文:https://stackoverflow.com/questions/3924674
更新时间:2023-10-11 06:10
最满意答案
您的表格实际上应采用不同的结构,以使您的生活更轻松:
Goals: ID Goal 1 drinkMoreWater 2 goToBedEarly 3 callADearFriend Status: ID Status 1 Success 2 Fail Tracking: ID Date Goal_ID Status_ID 1 1/1/2012 1 1 1 1/1/2012 3 2 1 1/2/2012 2 1 1 1/2/2012 4 1
现在您可以轻松添加目标和状态(例如“正在处理它”),并且您的表结构不必更改以适应您的更改,您的查询也变得更加简单。
Your tables should actually be structured differently to make your life easier:
Goals: ID Goal 1 drinkMoreWater 2 goToBedEarly 3 callADearFriend Status: ID Status 1 Success 2 Fail Tracking: ID Date Goal_ID Status_ID 1 1/1/2012 1 1 1 1/1/2012 3 2 1 1/2/2012 2 1 1 1/2/2012 4 1
Now you could easily add goals and status (e.g. 'Working on it') and your table structure does not have to change to accommodate your changes, your queries become a lot simpler as well.
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
计算出现次数(Count number of occurences)[2022-08-08]
如果您在MySql中工作,则不能直接使用参数化列名称。 有一种使用存储过程和预处理语句的间接方法。 一些草率的第一草案代码...注意反引号`和引号' CREATE PROCEDURE CountTables() BEGIN DECLARE done TINYINT DEFAULT 0; DECLARE table_name varchar(30), colunn_name varchar(30); DECLARE cur1 CURSOR FOR SELECT ... -
计算按行划分的列数,超过dataframe中的值(Count number of columns by row that exceed a value in dataframe)[2023-06-06]
我建议像 Base$Count1 <- rowSums(Base[,grep("^NT", names(Base))] > Base$Limit1, na.rm=T) Base$Count2 <- rowSums(Base[,grep("^NT", names(Base))] > Base$Limit2, na.rm=T) 这产生了 ID NT1 NT2 NT3 NT4 NT5 NT6 Limit1 Limit2 Count1 Count2 1 001 1 1 1 NA NA ... -
如何计算连接表的每一行中值的出现次数?(How do I count the occurences of the values in each row of a joined table?)[2022-04-28]
SELECT first_name, last_name, customer.email, visits FROM customer JOIN (SELECT email_, COUNT(*) AS visits FROM bookings GROUP BY email_) v ON customer.email = v.email_ SELECT first_name, last_name, customer.ema ... -
您可以将函数应用于data.frame的所有列。 假设您要计算data.frame d每列中的“A”数 #a sample data.frame L3 <- LETTERS[1:3] (d <- data.frame(cbind(x = 1, y = 1:10), fac = sample(L3, 10, replace = TRUE))) # the function you are looking for apply(X=d,2,FUN=function(x) lengt ...
-
Excel计算值在列中显示的次数(如果该行唯一)(Excel count number of times a value appears in column, if unique to the row)[2024-03-17]
在A列中尝试这个(对于另一列,将A2:A11="#"更改为A2:A11="#"到B2:B11="#" ,依此类推): =SUMPRODUCT((A2:A11="#")*(MMULT(IF(A2:D11="#",1,0),TRANSPOSE(COLUMN($A$2:$D$2)/COLUMN($A$2:$D$2)))=1)) 其中A2:D11是数组的地址, A2:A11第一列的A2:A11地址。 注意,因为它是一个数组公式,你应该按CTRL + SHIFT + ENTER来评估它。 Try this one ... -
您的表格实际上应采用不同的结构,以使您的生活更轻松: Goals: ID Goal 1 drinkMoreWater 2 goToBedEarly 3 callADearFriend Status: ID Status 1 Success 2 Fail Tracking: ID Date Goal_ID Status_ID 1 1/1/2012 1 1 1 1/1/201 ...
-
这是典型的ave + seq_along类型的问题,但我们需要先将数据转换为向量: t(`dim<-`(ave(rep(1, prod(dim(x[, -1]))), c(t(x[, -1])), FUN = seq_along) - 1, rev(dim(x[, -1])))) # [,1] [,2] [,3] # [1,] 0 0 0 # [2,] 1 1 0 # [3,] 1 2 0 ...
-
我的解决方案类似于你的,只添加.apply(lambda x: pd.Series(x.unique()), axis=1)用于删除行中的重复项,另一种可能的解决方案是使用groupby和unstack快速调整size : grouped = df.set_index('EVALUATED') .filter(like='TYPE_') .apply(lambda x: pd.Series(x.unique()), axis=1) .s ...
-
public void BindStates(DataTable states) { int numberUsa = 0; foreach (DataRow row in states.Rows) { if (row[1].ToString() == "USA") { numberUsa++; } } Console.WriteLine(numberUsa.ToString()); } pub ...