我在尝试从C++库中找出排序函数并尝试从az对这个字符串数组进行排序时遇到了很多麻烦,请帮助!
我被告知使用这个,但我无法弄清楚我做错了什么.
// std::sort(stringarray.begin(), stringarray.end());
Run Code Online (Sandbox Code Playgroud)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int z = 0;
string name[] = {"john", "bobby", "dear",
"test1", "catherine", "nomi",
"shinta", "martin", "abe",
"may", "zeno", "zack", "angeal", "gabby"};
sort(name[0],name[z]);
for(int y = 0; y < z; y++)
{
cout << name[z] << endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用彩色按钮混合任何颜色组合,这些按钮输出特定的十六进制数字与引导程序中的滑动条组合,允许用户指示他们想要使用的颜色百分比.
我无法让滑块正常运行,我不知道为什么.
我确实需要一些帮助将这些代码组合成一个可以用于我的艺术课程的工作算法.完整的代码可以在这里找到:
https://jsfiddle.net/mw7optL5/289/
//Hex blending algorithm
var mix = function(color_1, color_2, weight) {
function d2h(d) { return d.toString(16); } // convert a decimal value to hex
function h2d(h) { return parseInt(h, 16); } // convert a hex value to decimal
weight = (typeof(weight) !== 'undefined') ? weight : 50; // set the weight to 50%, if that argument is omitted
var color = "#";
for(var i = 0; i <= 5; i += 2) { // loop through each …Run Code Online (Sandbox Code Playgroud) 我已经有了一个不错的算法,能够将CMYK颜色组合在一起。但是,它不能不失败地组合其他十六进制颜色。我想帮我弄清楚如何编辑算法以接受其他颜色。我知道它可以对几种颜色进行颜色混合,就像我在其他在线免费应用程序中看到的那样。
我要进行的另一种修改是使总体混合比例为100%。目前,您可以将所有颜色的比例提高到100%,但我想将每种颜色的比例都提高到100%。
完整的代码可以在这里找到:https : //jsfiddle.net/5dsgbne9/30/
这是需要修改的主要混色算法
var slider = new Slider('#ex1', {
formatter: function(value) {
return 'Current value: ' + value;
}
});
var colorPercentages = {};
var colors = document.getElementsByClassName("colors");
for (let i = 0; i < colors.length; i++) {
if (!(colors[i].getAttribute("id") in colorPercentages)) {
colorPercentages[colors[i].getAttribute("id")] = 0;
}
colors[i].addEventListener("click", function() {
colorPercentages[colors[i].getAttribute("id")] = $("#ex1").val();
colors[i].innerHTML = colors[i].getAttribute("id") + " " + $("#ex1").val() + "%";
console.log(colorPercentages)
//formula here!!
let r = 255 * (1 - colorPercentages.Cyan / 100) …Run Code Online (Sandbox Code Playgroud) 我这里有一个简单的问题,但不知道如何解决这个问题!我正在尝试创建一个数字生成器,但我只想从1-6中选择一个随机数.没有零!这个问题被标记为dup但不应该是因为这是C++ NOT C:
srand(static_cast<unsigned int>(time(0)));
int dice = rand()%6;
Run Code Online (Sandbox Code Playgroud) 我试图使用一个小脚本来提取数据,我发现它似乎与生成json数据的任何其他url一起工作,但是当我使用它以.json结尾的url时,我只会收到语法错误.
//错误
Uncaught SyntaxError: Unexpected token : http://frontier.ffxiv.com/worldStatus/gate_status.json?callback=jQuery21309476937903091311_1450254419566&q=select+title%2Cabstract%2Curl+from+search.news+where+query%3D%22cat%22&format=json&_=1450254419567
Run Code Online (Sandbox Code Playgroud)
//下面的代码
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
// Using YQL and JSONP
$.ajax({
url: "http://frontier.ffxiv.com/worldStatus/gate_status.json",
// The name of the callback parameter, as specified by the YQL service
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Tell YQL what we want and that we want JSON
data: {
q: "select title,abstract,url from search.news where query=\"cat\"",
format: "json"
},
// Work with the response
success: function( response ) {
console.log( response ); // …Run Code Online (Sandbox Code Playgroud) 我收到有关非静态成员的无效使用以及结构成员无法正常工作的其他问题的错误,我无法理解问题所在,谢谢.
#include <iostream>
#include <string>
using namespace std;
struct classroom {
int RoomNumber;
int NumberOfChairs;
int NumberOfStudents;
int ListOfStudents[NumberOfStudents];
string LectureName;
bool Window, Projector, Available;
}classroom;
int main() {
cout << "Please enter your room number" << endl;
cin >> classroom.RoomNumber;
cout << "Enter the name of the Lecture" << endl;
cin >> classroom.LectureName;
cout << "Enter number of students" << endl;
cin >> classroom.NumberOfStudents;
cout << "Enter " << classroom.NumberOfStudents << " Student Names" << endl;
cin >> classroom.ListOfStudents; …Run Code Online (Sandbox Code Playgroud) 我JFrame没有显示构造函数中设置的按钮或背景颜色.我启动程序时只得到一个空白框.不确定代码有什么问题.
//imports
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;;
public class StartingTheCode{
JButton CalculateButton;
JTextField Ans;
JPanel p;
JFrame f;
public static void main (String[] args){
new StartingTheCode();
}
//constructor
StartingTheCode(){
f = new JFrame("test");
f.setVisible(true);
f.setSize(600,600);
f.setLocationRelativeTo(null);
f.setResizable(false);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p = new JPanel();
p.setBackground(Color.BLUE); // not displaying blue background
CalculateButton = new JButton("+"); // should display button
CalculateButton.setSize(30,30);
CalculateButton.setLocation(5,5);
}
}
Run Code Online (Sandbox Code Playgroud) 我收到一个奇怪的错误,我完全不确定它的来源,android 清单似乎没有我能看到的任何问题。我还添加了主要活动。
错误日志
11-27 09:53:12.364 2553-2553/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.capstoneproject.capstoneproject, PID: 2553
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.capstoneproject.capstoneproject/com.example.capstoneproject.capstoneproject.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.widget.Button.findViewById(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
Run Code Online (Sandbox Code Playgroud)
安卓清单
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
主要活动
package com.example.capstoneproject.capstoneproject;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu; …Run Code Online (Sandbox Code Playgroud) 由于某种原因,无论变量"msg"存储了什么,此语句都会触发.它应该只响应您在代码中看到的内容.如果我正确地写了这个陈述,或者我需要用另一种方式格式化,请告诉我.谢谢
if (username == "ssj3goku878") or (username == "mgnlive") and msg == "!load":
keyholder.holdForSeconds("F7", 1);
if (username == "ssj3goku878") or (username == "mgnlive") and msg == "!save":
keyholder.holdForSeconds("F8", 1);
Run Code Online (Sandbox Code Playgroud)