与字符逆序(一)不同,句子逆序,单词顺序.例如:I am a student 输出为student a am I. 想法:先字符串句子逆序,然后针对每个单词再逆序一遍. package test; import java.util.Scanner; //一个句子单词顺序,句子逆序 public class exam10 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); whil…
python列表和字符串的三种逆序遍历方式 列表的逆序遍历 a = [1,3,6,8,9] print("通过下标逆序遍历1:") for i in a[::-1]: print(i, end=" ") print("\n通过下标逆序遍历2:") for i in range(len(a)-1,-1,-1): print(a[i], end=" ") print("\n通过reversed逆序遍历:") f…
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ le…
将一个字符串str的内容颠倒过来,并输出.str的长度不超过100个字符. 如:输入“I am a student”,输出“tneduts a ma I”. package test; import java.util.Scanner; /* 一个句子单词逆序.句子逆序 */ public class exam09 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while…