首页 \ 问答 \ 遍历矢量的每个元素(Looping through each element of a vector)

遍历矢量的每个元素(Looping through each element of a vector)

所以假设我有一个向量,它包含4个elemens [string elements]。 我需要首先循环遍历向量,然后遍历每个元素,循环遍历字符数组[元音]并计算该单词包含多少个元音。

    for(int i = 0; i < b.size(); i++) 
    {
      for(int j = 0; j < b[i].size(); j++) 
       {
         for(int v = 0 ; v < sizeof( vowels ) / sizeof( vowels[0] ); v++)
          if(//blabla)
       }
    }

所以我的问题是,我如何循环每个单词,我的意思是b[i][j]是正确的方法来做到这一点?

如果是的话,这个表格会很好吗? :

if(b[i][j] == vowels[v]) {
//blabla
}

谢谢。


so let's say i have a vector, wich contains 4 elemens [string elements]. I need to loop through the vector first , then through each element , loop through an array of chars [vowels] and to count how many vowels does that word contain.

    for(int i = 0; i < b.size(); i++) 
    {
      for(int j = 0; j < b[i].size(); j++) 
       {
         for(int v = 0 ; v < sizeof( vowels ) / sizeof( vowels[0] ); v++)
          if(//blabla)
       }
    }

so my question is, how can i loop through each word , i mean b[i][j] is the right way to do that?

if yes, this form , will work great? :

if(b[i][j] == vowels[v]) {
//blabla
}

thanks.


原文:https://stackoverflow.com/questions/9246920
更新时间:2022-03-18 12:03

最满意答案

基本上,问题可能是因为:

  • Android上的OpenCL并未得到Google的正式支持。 因此,您可能会看到某些Android设备上不支持OpenCL。 虽然到目前为止,大多数旗舰设备都支持OpenCL,例如配备Qualcomm / Samsung芯片组的设备(除了谷歌Nexus设备,但有一些Nexus设备的解决方法,请谷歌在线)。
  • 如果您清楚地知道您的应用只能在支持OpenCL的某些设备上运行,您可以继续执行此操作。 高通和三星芯片组的OpenCL目前非常稳定,编译器已经优化了很多年; 因此,您可以从这些设备中获得一些良好的性能。

Basically, the problem may have caused as because :

  • OpenCL on Android is not officially support by Google. Therefore, you may expect to see the OpenCL not supported on some Android devices. Though, so far, most of the flagship devices have the OpenCL support, such as devices with Qualcomm/Samsung chipsets (except Google Nexus devices, but there is workaround for some Nexus devices, please google online).
  • If you clearly know your app will run only on certain devices, which support OpenCL, you can go ahead to do it. The OpenCL on Qualcomm and Samsung chipsets is pretty stable right now, and the compiler has been optimized for quite a few years; therefore, you can expect some good performance out of those devices.

相关问答

更多
  • 奥基! 我想我知道如何合并您的项目,因为我自己的项目也遇到了这种问题。 它帮助我从github下载并打开了一个示例项目。 请按照我的指南: 解: 在Android Studio中下载并打开MaterialiseYourApp 将使用的导入方法与您的导入方法进行比较,并将其并排使用 重要文件: includes_toolbar.xml , drawer_header.xml 这里给出了一个非常好的教程: 设计支持库(I):导航视图 我无法真正插入代码片段,因为您需要整个项目.. 请评价我的答案并给我反馈! : ...
  • 四种不同的文件适用于四种不同的体系结构 - ar64-v8a,armeabi-v7a,x86,x86-64。 根据您计划支持的体系结构,您必须在libs下添加相应的文件夹,并在该文件夹内复制相应的.so文件。 因此,如果您打算仅支持armeabi-v7a,那么您必须在libs文件夹内创建名为armeabi-v7a的文件夹,并将armeabi-v7a文件添加到它。 The four different files you have are for the four different architecture ...
  • 您可以使用testNG运行您想要的任何类型的测试用例。 您可以创建一个测试包,然后创建一个测试类来开始编写测试。 假设您的类名为AndroidTests.java,您需要导入testng并开始编写测试,如下所示: @Test public void test1() { //Test logic here assert someAssert; } 然后,当您有足够的测试用例时,您需要创建您的套件:
  • 这是告诉你,libOpenCL.so和libGAL.so正在使用硬浮点和VFP单元,但是你的程序被编译为一个使用软浮点的程序。 使用-mfloat-abi=hard标志,并可能使用-mfpu=vfp标志(请参阅gcc手册页了解可能适合的其他vfp变体)。 如果您的平台不支持硬浮动ABI,或者您的处理器没有浮点单元,则不能使用这两个库。 This is telling you that libOpenCL.so and libGAL.so are using hard floating points and ...
  • 如果您需要所有社交网络,请尝试使用此库。 socialauth If you need all social networks, try this library. socialauth
  • 您可以尝试寻找集成名为SwiftBraille的第三方库。 这可能是你正在寻找的。 然后为了给用户选择一个键盘,你可以使用: InputMethodManager inputManager = (InputMethodManager) getApplicationContext().getSystemService(INPUT_METHOD_SERVICE); inputManager.showInputMethodPicker(); 如果您在切换键盘时遇到麻烦,您可以查看其他答案 。 You can t ...
  • 你必须检查cpu abi版本,并更改geckoview_library和geckoview_asset以匹配abi。 http://ftp.mozilla.org/pub/mozilla.org/mobile/nightly/ 从链接中,您可以下载几种geckoview库。 这是一个样本。 [DIR] latest-mozilla-central-android-armv6/ 12-Dec-2013 11:50 - [DIR] latest-mozilla-central-andro ...
  • 基本上,问题可能是因为: Android上的OpenCL并未得到Google的正式支持。 因此,您可能会看到某些Android设备上不支持OpenCL。 虽然到目前为止,大多数旗舰设备都支持OpenCL,例如配备Qualcomm / Samsung芯片组的设备(除了谷歌Nexus设备,但有一些Nexus设备的解决方法,请谷歌在线)。 如果您清楚地知道您的应用只能在支持OpenCL的某些设备上运行,您可以继续执行此操作。 高通和三星芯片组的OpenCL目前非常稳定,编译器已经优化了很多年; 因此,您可以从这些 ...
  • 你已经走上正轨了! 您找到的是Cordova最受欢迎的相机插件: https://github.com/apache/cordova-plugin-camera 虽然这是一个纯粹的科尔多瓦插件,这意味着它对Ionic不做任何调整。 这意味着,您只需将它添加到您的项目中,一旦Ionic准备好就可以使用它: ionic.Platform.ready( function() { navigator.camera.getPicture(onSuccess, onFail, options); }); 但是,将 ...
  • 目前还不是很清楚你遇到了什么问题,但是我最近还会尝试一下这个问题。 这些是我采取的步骤: 使用classpath 'com.android.tools.build:gradle:2.2.0作为我的构建工具版本 在我的app/src/main/jni目录中添加了C库 在我的app/src/main/jni目录中添加了一个Android.mk和Application.mk文件 在我的app/build.gradle添加了以下app/build.gradle : ``` externalNativeBuild { ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)