找到 34423 篇文章 编程

在 C++ 中将 ASCII 值句子转换为等效字符串

Ayush Gupta
更新于 2020年1月22日 07:35:38

702 次浏览

在本教程中,我们将讨论一个将 ASCII 值句子转换为等效字符串的程序。为此,我们将提供一个包含 ASCII 代码的字符串。我们的任务是将给定的字符串转换为等效字符并将其打印出来。示例实时演示#include using namespace std; //将 ASCII 序列转换为//字符字符串 void convert_ASCII(string str, int len){    int num = 0;    for (int i = 0; i < len; i++) {       //追加当前数字       num = num * 10 + (str[i] - '0');       //检查数字是否在范围内       if (num >= 32 && num

在 C++ 中转换数组,使其 GCD 变为 1

Ayush Gupta
更新于 2020年1月22日 07:28:31

229 次浏览

在本教程中,我们将讨论一个将数组转换为数组的 GCD 变为 1 的程序。为此,我们将提供一个数组和一个正整数 k。我们的任务是转换数组元素,使其 GCD 为 1,同时仅将数组元素除以 k 任意次数,直到元素小于 k。示例实时演示#include using namespace std; //计算数组的 GCD int calculate_gcd(int* arr, int n){    int gcd = arr[0];    for (int i = 1; i < n; i++) ... 阅读更多

在 C++ 中将三元表达式转换为二叉树

Ayush Gupta
更新于 2020年1月22日 07:23:09

187 次浏览

在本教程中,我们将讨论一个将三元表达式转换为二叉树的程序。为此,我们将提供一个三元表达式。我们的任务是根据各种可能的路径(选择)将给定表达式转换为二叉树的形式。示例实时演示#include using namespace std; //树的节点结构 struct Node {    char data;    Node *left, *right; }; //创建新节点 Node *newNode(char Data){    Node *new_node = new Node;    new_node->data = Data;    new_node->left = new_node->right = NULL;    return new_node; } //将三元表达式转换为二叉树 Node ... 阅读更多

在 C++ 中将字符串转换为二进制序列

Ayush Gupta
更新于 2020年1月22日 07:18:22

1K+ 次浏览

在本教程中,我们将讨论一个将字符串转换为二进制序列的程序。为此,我们将提供一个字符字符串。我们的任务是将每个字符转换为其二进制等效项并将其打印出来,并在不同字符之间用空格分隔。示例实时演示#include using namespace std; //转换为二进制等效项 void convert_binary(string s){    int n = s.length();    for (int i = 0; i 0){          (val % 2)? bin.push_back('1') :          bin.push_back('0');          val /= 2;       }       reverse(bin.begin(), bin.end());       cout

在 C++ 中将单链表转换为 XOR 链表

Ayush Gupta
更新于 2020年1月22日 07:13:44

204 次浏览

在本教程中,我们将讨论一个将单链表转换为 XOR 链表的程序。为此,我们将提供一个单链表。我们的任务是获取该列表的元素并将其转换为 XOR 链表。示例实时演示#include using namespace std; //链表的节点结构 struct Node {    int data;    struct Node* next; }; //创建新节点 Node* newNode(int data){    Node* temp = new Node;    temp->data = data;    temp->next = NULL;    return temp; } //打印单链表 void print(Node* ... 阅读更多

在 C++ 中将单链表转换为循环链表

Ayush Gupta
更新于 2020年1月22日 07:07:07

440 次浏览

在本教程中,我们将讨论一个将单链表转换为循环链表的程序。为此,我们将提供一个单链表。我们的任务是获取该列表的元素并将其转换为循环链表。示例实时演示#include //链表的节点结构 struct Node {    int data;    struct Node* next; }; //将单链表//转换为循环链表 struct Node* circular(struct Node* head){    struct Node* start = head;    while (head->next != NULL)       head = head->next;    //将 start 分配给... 阅读更多

在 C++ 中将最小堆转换为最大堆

Ayush Gupta
更新于 2020年1月22日 07:04:04

575 次浏览

在本教程中,我们将讨论一个将最小堆转换为最大堆的程序。为此,我们将提供最小堆的数组表示。我们的任务是在 O(n) 时间复杂度内将给定的最小堆转换为最大堆。示例实时演示#include using namespace std; //将给定子树转换为堆 void convert_arrayheap(int arr[], int i, int n){    int l = 2*i + 1;    int r = 2*i + 2;    int largest = i;    if (l < n && arr[l] > arr[i])       largest = l;    if (r ... 阅读更多

在 C++ 中将十六进制值字符串转换为 ASCII 值字符串

Ayush Gupta
更新于 2020年1月22日 07:00:38

2K+ 次浏览

在本教程中,我们将讨论一个将十六进制值字符串转换为 ASCII 值字符串的程序。为此,我们将提供一个包含一些十六进制值的字符串。我们的任务是获取该十六进制值并将其转换为等效的 ASCII 值。示例实时演示#include using namespace std; string convert_ASCII(string hex){    string ascii = "";    for (size_t i = 0; i < hex.length(); i += 2){       //从十六进制字符串中获取两个字符       string part = hex.substr(i, 2);       //将其更改为 16 进制       char ch ... 阅读更多

在 C++ 中将给定时间转换为文字

Ayush Gupta
更新于 2020年1月22日 06:56:25

249 次浏览

在本教程中,我们将讨论一个将给定时间转换为文字的程序。为此,我们将提供数字格式的特定时间。我们的任务是将该特定时间转换为文字示例#include using namespace std; //以文字形式打印时间 void convert_time(int h, int m){    char nums[][64] = {       "零", "一", "二", "三", "四",       "五", "六", "七", "八",       "九", "十", "十一", "十二",       "十三", "十四", "十五",       "十六", "十七", "十八",       "十九", "二十", "二十       一", ... 阅读更多

如何在 Java 中使用 lambda 和方法引用实现 LongPredicate?

raja
更新于 2020年7月14日 12:06:47

209 次浏览

LongPredicate 是在 java.util.function 包中定义的一个函数式接口。此接口主要用于评估类型为 long 的输入并返回类型为 boolean 的输出。LongPredicate 可用作 lambda 表达式或方法引用的赋值目标。它包含一个抽象方法:test() 和三个默认方法:and()、negate() 和 or()。语法@FunctionalInterface interface LongPredicate {  boolean test(long value); }Lambda 表达式的示例import java.util.function.LongPredicate; public class LongPredicateLambdaTest {    public static void main(String args[]) {       LongPredicate longPredicate = (long input) -> {    // lambda 表达式          if(input == 50) {       ... 阅读更多

广告

© . All rights reserved.