- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试以相反的顺序打印 tree_nodes
列表:
当前提示示例:/helloFellow/hello/root/>
期望的结果:root/hello/helloFellow/>
有什么方法可以有效地做到这一点?
// *prints the prompt (e.g. /bar/baz/ >) in every iteration of the main loop
// *show all directories on the path in correct order
void show_prompt(struct tree_node *cwd) {
struct tree_node *parDir = cwd->parent;
struct tree_node *originalDir = cwd;
while (cwd->parent != NULL) {
printf("/");
printf("%s", cwd->parent->string_buffer);
cwd = cwd->parent;
}
cwd = originalDir;
printf("/ >");
}
最佳答案
你可以使用递归:
void print_path( struct tree_node * cwd ) {
if ( cwd->parent != NULL )
print_path( cwd->parent );
printf( "%s/", cwd->string_buffer );
}
关于C: 如何倒序打印列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35244594/
我有这样的代码: Main 1 2 3 Another 4 5 我希望输出为: Main 3 2 1 Another 5 4 我正在尝试使用以下内容,但它无法正常工作: $.fn.reverseOrd
我在这个网站上找到了一个评论查询示例,它与我当前的数据库结构完美配合。 链接:How to make comment reply query in MYSQL? 接受的答案有效,但我想知道是否可以颠倒
我有带有字典列表(item0,item1,item2)的列表的Plist ..通常当我在屏幕上显示时..它按升序填充...item0 然后 item1 然后 item2......等等..我希望 Pl
我正在以相反的顺序使用回收站 View 来显示聊天记录。 如果聊天中只有一条消息,它会在底部显示消息(如电报)。但我需要从顶部显示它。 我被困在这一天了。谁能给我一个建议,让我以 Recyclervi
如何按数字从高到低对数组进行排序。 数组 ArrayList array1 = new ArrayList<>(); 类 public class TestClass{ public boole
欢迎, 我想知道是否可以在“按 desc 排序”排序中反转返回的数据,但我希望该数据以相反的顺序。 例如,我得到了带有值的表 ID 1 2 3 4 我愿意 按 ID 排序 ASC LIMIT 3我得到
我正在尝试在 FireFox 中模拟输入类型='number' 的逗号插入,因为它尚不支持它。天真地它在 Chrome 中工作。我让我的正则表达式开始工作...只是顺序不对,我需要将其反转。 http
我浏览了很多关于 z-index 的页面。这个例子应该在顶部显示棕色的数字列表(更高的 z-index?)而不是蓝色的文本框。 CSS 在此处的 HTML 中以便于调试: 我的理解是,只要两个 blo
从表中选择 id LIMIT 8, 3 结果在 8,9,10 但我需要 10,9,8 你怎么能做到这一点?如果您添加“ORDER BY id DESC”,它会得到 3,2,1 最佳答案 将您的查询放在
我想在使用 desc 后反转 SQL Server 中结果的顺序。例如: SELECT TOP 3 * FROM table ORDER BY id DESC 返回结果: 505 504 503 但是
我正在编写一条 Oracle SQL 语句来获取最近日期的值。如果我的表格如下所示: +============+=================+ | sv_version | sv_date_a
我正在编写一条 Oracle SQL 语句来获取最近日期的值。如果我的表格如下所示: +============+=================+ | sv_version | sv_date_a
我是一名优秀的程序员,十分优秀!