我正在尝试实现自己的strcmp
功能,strcmp
当我使用特殊字符时,我的bahaves不同.
#include <string.h>
int my_strcmp(const char *s1, const char *s2)
{
const char *str1;
const char *str2;
str1 = s1;
str2 = s2;
while ((*str1 == *str2) && *str1)
{
str1++;
str2++;
}
return (*str1 - *str2);
}
int main()
{
char *src = "a§bcDef";
char *des = "acbcDef";
printf("%d %d\n", my_strcmp(des, src), strcmp(des, src));
return(0);
}
Run Code Online (Sandbox Code Playgroud)
OUTPUT
161-95
我得到了一个任务堆栈数排序a
中使用两个栈升序排列的整数a
和b
.
使用11个操作:
swap a
- 交换堆栈顶部的前2个元素a
swap b
- 交换堆栈顶部的前2个元素b
.sa
和sb
在同一时间.push a
- 取第一个元素放在顶部,b
然后放在顶部a
.push b
- 取第一个元素放在顶部,a
然后放在顶部b
.rotate a
- 将堆栈a
的所有元素向上移动1.第一个元素成为最后一个元素.rotate b
- 将堆栈b
的所有元素向上移动1.第一个元素成为最后一个元素.ra
和rb
在同一时间.rotate a
- 向下移动堆栈a
的所有元素1.最后一个元素成为第一个元素.我正在尝试将 javascript 字符串显示为 jsx,似乎无法在 react native 中将字符串显示为 jsx,例如const test = '<Text>hello</Text>'
render() { return ({test})}
.
给定以下字符串
const svg = '<Svg.G fill="none" fill-rule="evenodd"> <Svg.Path fill="none" d="M0 0h24v24H0z"/> <Svg.Path stroke="#333" stroke-linecap="round" stroke-linejoin="round" d="M3.5 12.5h17v9h-17zM13.5 12.5v9M10.5 12.5v9M1.883 9.602l18.353-4.918.776 2.898L2.66 12.5z"/> <Svg.Path stroke="#333" stroke-linejoin="round" d="M6 6.857c.957.553 4.675.393 4.675.393S8.957 3.945 8 3.393a2 2 0 1 0-2 3.465zM15.296 4.366c-.546.956-3.852 2.674-3.852 2.674s-.164-3.718.388-4.674a2 2 0 1 1 3.464 2z"/> <Svg.Path stroke="#333" stroke-linecap="round" stroke-linejoin="round" d="M12.508 6.755l.777 2.897M9.61 7.531l.776 2.899"/></Svg.G>';
Run Code Online (Sandbox Code Playgroud)
然后我想像下面这样渲染它
render() {
return (
<View>
<Svg>
{svg} …
Run Code Online (Sandbox Code Playgroud) 我正在创建一个单实例应用程序,该应用程序最小化到系统托盘,我想显示当前正在运行的实例,然后退出新实例。我怎样才能创建这个功能?
主程序
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QIcon>
#include <QQuickWidget>
#include <QSystemTrayIcon>
#include <QQmlContext>
#include <QQmlEngine>
#include <QSystemSemaphore>
#include <QSharedMemory>
// Declare a user-defined data type to work with an icon in QML
Q_DECLARE_METATYPE(QSystemTrayIcon::ActivationReason)
Q_DECL_EXPORT int main(int argc, char *argv[])
{
#if defined(Q_OS_WIN)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QApplication app(argc, argv);
QQmlApplicationEngine engine;
QSystemSemaphore semaphore("deploy", 1); // create semaphore
semaphore.acquire(); // Raise the semaphore, barring other instances to work with shared memory
#ifndef Q_OS_WIN32
// in linux / unix shared memory is not …
Run Code Online (Sandbox Code Playgroud) 我创建了一个数组列表并在列表视图中显示它,并带有简单的列表项多项选择,但我无法检查或勾选列表中的项,当我单击这些项时什么也没有发生。请检查下面的代码并告诉我我做错了什么。
package com.example.arrays;
import java.util.Random;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemLongClickListener;
public class MainActivity extends Activity {
ListView showList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView show = (TextView)findViewById(R.id.txtShow);
final Random generate = new Random();
showList = (ListView)findViewById(R.id.listView1);
final String[] myAttraction = new String[4];
myAttraction[0]= "Walter Sisulu National Botanical Garden ";
myAttraction[1]= "Coca-Cola Dome";
myAttraction[2]= "Promusica Theatre";
myAttraction[3]= "Unisa …
Run Code Online (Sandbox Code Playgroud) 我试图实现gecthar
,使用read
,问题是,当我使用my_getchar()
与printf
我的功能之前执行printf
.
#ifndef BUFF_SIZE
#define BUFF_SIZE 1023
#endif
int my_getchar(void)
{
static char buff[BUFF_SIZE];
static char *chr;
int ret;
if ((ret = read(STDIN_FILENO, buff, BUFF_SIZE)) > 0)
{
chr = buff;
return (*chr);
}
return (EOF);
}
Run Code Online (Sandbox Code Playgroud)
在我的 main()
char c;
printf("Enter character: "); // if I put '\n' line here, it works fine
c = my_getchar();
printf("Character entered: ");
putchar(c);
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我想在我的组件(边框底部)中重现该样式。我基本上加载一个矩形图像,然后我想在底部将其圆角化。
我想想 :
有没有办法用 React-Native 以正确的方式做到这一点?
谢谢 !