我需要找到图形的2个顶点之间的最短路径.我有一个矩阵,其中包含所有权重.我该怎么做?目前,我有以下代码:
private int[] Dijkstra(int start, int end)
{
bool[] done = new bool[8];
int[] parent = new int[8];
for (int i = 0; i < parent.Length; i++)
parent[i] = -1;
int[] distances = new int[8];
for (int i = 0; i < distances.Length; i++)
distances[i] = int.MaxValue;
distances[start] = 0;
int current = start;
while (!done[current])
{
done[current] = true;
for (int i = 0; i < 8; i++)
{
if (graph[current, i] != int.MaxValue)
{
int dist = graph[current, …Run Code Online (Sandbox Code Playgroud) Stackoverflow用户!
我正在使用Borland C++ Builder 6来创建我的程序.是的,我知道它已经过时了两年,但是,我必须使用这个IDE.我有一个我需要拆分的字符串.所以我使用以下方法:
void Orders::split(TStringList* lout, char* str, const char* separator) {
for(char* tok = strtok(str, separator); tok!=NULL; tok = strtok(NULL, separator))
lout->Add(tok);
}
Run Code Online (Sandbox Code Playgroud)
另外,我有一个定义为预处理器常量的分隔符:
#define SEPARATOR ':'
Run Code Online (Sandbox Code Playgroud)
然后我调用split方法
split(ords, input.c_str(), SEPARATOR);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[C++错误] File3.cpp(47):E2034无法将'int'转换为'const char*'
在线上,我称之为split方法.转换为const char*会导致相同的结果.IDE中是否存在错误,或者我是否因为在代码中看到自己的错误而愚蠢?
提前致谢!
在我的android应用程序中,我需要从麦克风捕获用户的语音,然后将其传递给服务器。目前,我使用MediaRecorder该类。但是,它不能满足我的需要,因为我想基于当前输入声音的音量来产生发光效果,所以我需要一个AudioStream或类似的东西。当前,我使用以下内容:
this.recorder = new MediaRecorder();
this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
this.recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
this.recorder.setOutputFile(FILENAME);
Run Code Online (Sandbox Code Playgroud)
我正在使用API级别7进行编写,因此看不到任何其他AudioEncoders,但是看不到AMR Narrow Band。也许这就是我在录音中听到的可怕声音的原因。
我面临的第二个问题是音质差,噪音小,所以我想减少(取消,抑制)它,因为它确实很糟糕,尤其是在我的中文平板电脑上。这应该是服务器端的,因为据我所知,它需要大量资源,而且并非所有现代小工具(尤其是没有名字的中国平板电脑)都可以尽可能快地做到这一点。我可以自由选择要在服务器上使用的平台,因此可以是ASP.NET,PHP,JSP或任何可以帮助我改善声音的东西。说到ASP.NET,我遇到了一个名为NAudio的库,也许它可以在某种程度上帮助我。我知道,该库中没有内置任何降噪解决方案,但是我发现了一些使用它进行FFT和自动迭代的示例,因此可能会有所帮助。
老实说,我从来没有这么近的声音过,我也不知道从哪里开始。我在Google上搜索了很多有关降噪技术,代码示例的内容,但一无所获。你们是我最后的希望。
提前致谢。
我有一个Android应用程序在使用Android 2.3.3的AVD上完美运行,但它无法安装在任何可供我测试的设备上(索尼爱立信XPeria运行Android 2.3.3,LG Optimus运行Android 2.3.7和三星Galaxy Tab Android 4.0.3).错误是"未安装应用程序".据我所知,它可能与应用程序的不正确的清单文件相关联,所以AndroidManifest.xml如果它可能会有帮助,请转到我的位置:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hohlocola"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission
android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HohloColaActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Run Code Online (Sandbox Code Playgroud)
我导出我的应用程序未签名.
提前致谢!