步骤和楼梯的C程序(C program for steps and stairs)
所以我正在编写一个程序,我们可以一次性获取楼梯总数和步数。 所以举个例子。
让我们说
stairs=10; steps=3;
所以从零开始。 它去了。 0-1-2。 然后回到1并进入1-2-3,2-3-4,3-4-5,4-5-6,依此类推,直到8-9-10。
我为它编写了代码。 但缺少一些东西。 这里是:#include<stdio.h> int main() { int i,j,stair,step; stair=10; step=3; for(i=0;i<=stair;i++) { for(j=1;j<=step;j++) { printf("\nJ:::%d",j); } printf("\tI:::%d",i); } }
而不是只提供代码。 有人可以用逻辑来帮助我吗? 非常感谢提前。
So I am writing a program where we take input on total number of stairs and number of steps in one go. So for example.
Lets say
stairs=10; steps=3;
So starting from zero. It goes. 0-1-2. Then Goes back to 1 and goes 1-2-3, 2-3-4, 3-4-5, 4-5-6 and so on till 8-9-10.
I wrote code for it. But something is missing. Here it is:#include<stdio.h> int main() { int i,j,stair,step; stair=10; step=3; for(i=0;i<=stair;i++) { for(j=1;j<=step;j++) { printf("\nJ:::%d",j); } printf("\tI:::%d",i); } }
Instead of giving just code. Can someone help me with logic ? Thanks a lot in advance.
原文:https://stackoverflow.com/questions/35455154
满意答案
那么,如果你想满足两个案例(
recordtype
==Income
&&recordtype
==Your Date
),那么为什么你不使用&&
筛选?recordFilter = record.filter { return $0.recordtype!.contains("Income") && $0.createdAt! == recordItem.createdAt!}
如果我错过了什么,请试一试让我知道吗?
如果你想在这里求和,你去:
recordFilter.map{($0["amount"] as! Float)}.reduce(0, +)
Well, If you want to fulfil two cases (
recordtype
==Income
&&createdAt
==Your Date
) so why you are not filtering using the&&
?recordFilter = record.filter { return $0.recordtype!.contains("Income") && $0.createdAt! == recordItem.createdAt!}
Please give a try and let me know if I am missing something?
If you want to sum here you go:
recordFilter.map{($0["amount"] as! Float)}.reduce(0, +)
相关问答
更多Swift:按键引用数组元素(Swift: reference to array element by key)
在Swift数组中找到元素的总和(Finding sum of elements in Swift array)
Swift:将数组作为值过滤字典(Swift: Filter a Dictionary with Array as Value)
查找峰值元素(多个)SWIFT(Find peak elements (multiple) SWIFT)
如何过滤swift 4的对象数组,然后删除(How to filter array of objects swift 4 then remove after)
在数组中找到元素的总和(Find sum of elements in the array)
Swift:通过比较类型过滤协议数组(Swift: filter protocol array by comparing types)
如何通过多个元素过滤数组并在Swift中找到总和?(How to filter the array by multiple element and find the sum in Swift?)
如何在Swift中找到2d数组中所有元素的总和?(How to find the summation of all elements in 2d array in Swift?)
如何使用OR子句在Swift中过滤数组(How to use an OR clause to filter an array in Swift)
相关文章
更多《编程之道 Java》(Program JAVA)[ISO]
upgrade steps
《Objective-C 程序设计(第4版)》扫描版[PDF]
C程序访问Hadoop
基于C#的UDP协议的同步实现
Hadoop下的Pipes(用C++进行Hadoop程序开发)
C#.net门网页打印程序
【Hadoop学习】在伪分布式Hadoop上实践word count程序——C/C++ Pipes版本
C程序访问Hadoop运行时遇到的各种问题以及解决方案
fw: 专访许鹏:谈C程序员修养及大型项目源码阅读与学习
最新问答
更多如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)
maven中snapshot快照库和release发布库的区别和作用
arraylist中的搜索元素(Search element in arraylist)
从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)
Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)
如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)
如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
从iframe访问父页面的id元素(accessing id element of parent page from iframe)
linux的常用命令干什么用的
Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!