标签: counting

C#列表中重复项的计数

我想知道如何计算winform应用程序中C#中列表中的所有重复字符串.

List<string> colorList = new List<string> { "red", "red", "yellow", "blue", "blue", "orange", "green", "red" };
Run Code Online (Sandbox Code Playgroud)

例如,我有上面的列表,计数将是5,因为"红色"出现3次,"蓝色"出现两次.

很高兴使用循环或LINQ或任何必要的东西.

在我的实际程序中,这个列表可以包含1000个条目,因此性能也需要考虑.

谢谢!

c# linq arrays list counting

2
推荐指数
2
解决办法
1859
查看次数

计算向量中大于数字的元素

我想计算大于c ++向量中元素个数的元素。阈值将从用户输入。

用于计数大于数字的元素的代码为:

ctr=count_if(v.begin(),v.end(), greater1);

对应功能:

bool greater1(int value)
{
   return value >= 8;
}
Run Code Online (Sandbox Code Playgroud)

问题是我仅在count_if函数调用之前才知道阈值(此处为8),因此我需要将阈值t作为参数传递。如何建立相同的?

c++ vector counting stdvector c++03

2
推荐指数
1
解决办法
252
查看次数

如何计算具有特定扩展名或名称的文件中的文件数量?

我的问题是,当文件夹中有很多不同类型的文件时,我想列出一个文件夹中有多少个具有特定扩展名或名称的文件。

例如,假设一个文件夹中有一堆不同类型的文件,我只想计算有多少个 jpg 文件。

我尝试了 stackoverflow 上其他人的问答中的下面的代码,它确实显示了文件夹中 jpg 文件的所有名称,但没有显示有多少 jpg 文件的数量。

import glob, os
filelist = os.listdir('D:\Train')
for file in filelist:
    if(file.endswith('jpg')):
        print(file)
Run Code Online (Sandbox Code Playgroud)

另外,我想知道是否有一种方法可以对名称中包含某些单词的文件进行计数。ex) 计算文件夹中名称中包含“fire”的所有 jpg 文件(fire01.jpgfire02.jpg等)

python count counting

2
推荐指数
1
解决办法
7262
查看次数

如何在 Goole 工作表中使用 COUNTUNIQUEIFS 和 OR 条件,其中单元格可以满足两个条件

我正在尝试查找工作表中满足多个条件的唯一行的数量。数据是这样的:

ID |TYPE
1  |T1;T2;T3
2  |T1;T7
3  |T2;T3
4  |T6
Run Code Online (Sandbox Code Playgroud)

我想要类型为 T1 或 T2 的 ID 计数。正确答案是 3(id 1,2 和 3 具有任一目标类型)

=countuniqueifs(A:A,B:B,{"*t1*","*t2*"}) 
Run Code Online (Sandbox Code Playgroud)

给我的答案是2。

任何帮助都非常感谢。

unique counting google-sheets count-unique google-sheets-formula

2
推荐指数
1
解决办法
5048
查看次数

如何有效地计算 24 位无符号整数中的前导零?

大多数clz()(软件实现)都针对 32 位无符号整数进行了优化

如何有效地计算 24 位无符号整数中的前导零?

UPD。目标的特点:

CHAR_BIT                 24
sizeof(int)              1
sizeof(long int)         2
sizeof(long long int)    3
Run Code Online (Sandbox Code Playgroud)

c counting unsigned-integer leading-zero

2
推荐指数
1
解决办法
1237
查看次数

neo4j - Count the number of duplicates in result

Community,

I am new to neo4j and I'm trying to get a list of nodes (that has not a specific relation) and count node name duplicates.

Query:

MATCH (e:ExampleNode)
WHERE NOT exists((e)-[:EXAMPLE_REL]->())
RETURN e.name as name, count(e.name) as count
Run Code Online (Sandbox Code Playgroud)

Result:

name count
name1 3
name23 1
name8 4

So far so good...

Beside the name of the node I also need some more values. This value makes each result unique and returns every node separately even (if the name is …

counting neo4j cypher

2
推荐指数
1
解决办法
581
查看次数

计算二维中包含原点的多边形数量

假设我们在 2D 空间中有 n 个位于凸位置的点。精确地选择(n,k)个不同的凸k边形(非退化)。是否有任何现有算法可以在 O(n log n) 时间内运行(对于固定 k)来计算包含原点的多边形数量?

我试图在文献中寻找任何此类算法,但只找到了 k=3 的算法。

algorithm geometry polygon counting computational-geometry

2
推荐指数
1
解决办法
97
查看次数

使用jquery计算iframe内的标签

iframe src是这样的: - <iframe src="http://mysite.com/testing.php?id=7632762"></iframe> 并且内容是动态的.如何在服务器端或客户端使用javascript 找出iframe中的<div><li><p>标签数量?-谢谢

tags iframe jquery counting

1
推荐指数
1
解决办法
1721
查看次数

C K&R 1.5.4字数统计练习1-9

我想知道为什么下面的代码不能像下面的代码那样工作.代码应该做的是删除多个连续的空格并只显示一个空格:所以"它的工作原理"变成"它的工作原理".第一段代码就像"它的工作原理"一样.

不行

#include <stdio.h>

main(){
    int c;
    int lastspace;

    lastspace = 0;
    while((c = getchar()) != EOF){
        if(c != ' ')
            putchar(c);
            lastspace = 0;
        if(c == ' '){
            if(lastspace == 0){
            lastspace = 1;
            putchar(c);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

作品

#include <stdio.h>

main(){
    int c
    int lastspace;

    lastspace = 0;
    while((c = getchar()) != EOF){
        if(c != ' ')
            putchar(c);
        if(c == ' '){
            if(lastspace != c){
            lastspace = c;
            putchar(c);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c spaces counting cpu-word

1
推荐指数
1
解决办法
154
查看次数

计算数组中的单词总数

我想计算这个数组中的单词并将它们显示为总数而不是每个单词显示的次数.

<?php
$array = array("abstract", "accident", "achilles", "acidwash", "afrojack", "aguilera");
print_r(array_count_values($array));
?>
Run Code Online (Sandbox Code Playgroud)

结果

Array ( [abstract] => 1 [accident] => 1 [achilles] => 1 [acidwash] => 1 [afrojack] => 1 [aguilera] => 1 )
Run Code Online (Sandbox Code Playgroud)

结果我想

6

php arrays search function counting

1
推荐指数
1
解决办法
1442
查看次数