#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my heart in Harvard Med School",
"Newark, Newark - a wonderful town",
"Dancing with a Dork",
"From here to maternity",
"The girl from Iwo Jima",
};
void find_track(char search_for[])
{
int i;
for (i = 0; i < 5; i++)
{
if (strstr(tracks[i], search_for))
printf("Track %i: '%s'\n", i, tracks[i]);
}
}
int main()
{
char search_for[80];
printf("Search for: ");
fgets(search_for, 80, stdin);
find_track(search_for);
getch();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是直接取自 Head First …
我正在尝试实现合并排序,但不知何故已经卡了一天。
[抱歉粘贴了大量代码,但没有它就无法做到]
执行:
归并排序 - 函数
int mergeSort(int arr[], int low, int high)
{
int half = (low + high) / 2 ; /* FInd the middle element */
if (low < high)
{
if (high - low == 1) /* If only one element, return */
return;
mergeSort(arr,low,half); /* Sort First Half */
mergeSort(arr,half, high); /* Sort Second Half */
merge(arr,low,half,high); /* Merge */
}
return SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
合并步骤 - 合并功能
int merge(int arr[], int low, int half, int …Run Code Online (Sandbox Code Playgroud) 我首先使用以下方法对冻结在我的数据集上的ResNet-50层进行了训练:
model_r50 = ResNet50(weights='imagenet', include_top=False)
model_r50.summary()
input_layer = Input(shape=(img_width,img_height,3),name = 'image_input')
output_r50 = model_r50(input_layer)
fl = Flatten(name='flatten')(output_r50)
dense = Dense(1024, activation='relu', name='fc1')(fl)
drop = Dropout(0.5, name='drop')(dense)
pred = Dense(nb_classes, activation='softmax', name='predictions')(drop)
fine_model = Model(outputs=pred,inputs=input_layer)
for layer in model_r50.layers:
layer.trainable = False
print layer
fine_model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
fine_model.summary()
Run Code Online (Sandbox Code Playgroud)
然后,我尝试使用以下方法对未冻结的图层进行微调:
model_r50 = ResNet50(weights='imagenet', include_top=False)
model_r50.summary()
input_layer = Input(shape=(img_width,img_height,3),name = 'image_input')
output_r50 = model_r50(input_layer)
fl = Flatten(name='flatten')(output_r50)
dense = Dense(1024, activation='relu', name='fc1')(fl)
drop = Dropout(0.5, name='drop')(dense)
pred = Dense(nb_classes, activation='softmax', name='predictions')(drop)
fine_model = …Run Code Online (Sandbox Code Playgroud) 我有一个枚举Eg.
enum {
APPLE,
MANGO,
BANANA
}
Run Code Online (Sandbox Code Playgroud)
和相应的字符串数组
char fruits[] =
{
"apple",
"mango",
"banana"
}
Run Code Online (Sandbox Code Playgroud)
我需要检索字符串的索引,因为我有字符串.因此,如果字符串是苹果,我需要得到0,依此类推.[ Enum另外,可能有助于解决方案]
是否有一种优雅的方式,保存[apple,0],[banana,1]简短,我可以用作宏.我不需要像哈希表那样冗长的东西.可以Enum协助映射吗?
这些是用于2D阵列的符号
char (*names)[5] ;
Run Code Online (Sandbox Code Playgroud)
和
char* names[] = {"Jan","Feb"};
Run Code Online (Sandbox Code Playgroud)
和
char names[3][5] = { Initializers..};
Run Code Online (Sandbox Code Playgroud)
我对这些符号感到非常困惑.
第一个声明名称是指向5个字符数组的指针,即
names -> a char pointer -> "Some string"
Run Code Online (Sandbox Code Playgroud)
第三个存储器映射具有不同的存储器映射,即它与行正常数组一样以行主要顺序存储,与上述不同.
第二种符号与第一种和第三种符号的相似或不同如何?
将它们传递给函数也是完全不同的故事.如果我们将2d数组声明为类型2,那么它将作为双指针(char** names)传递,而如果它是类型1或类型3,则应在声明中提及列.
请帮助我更清楚地了解这些问题.谢谢.
我有这个示例程序,当使用fstack-protector-all编译时会给出一个堆栈粉碎.
#include <stdio.h>
#include <stdint.h>
int func(int* value)
{
uint8_t port = 1;
*value = port; //Canary value changes at this point when seen in GDB
return 1;
}
int main()
{
uint16_t index = 0;
int ret = func((int*)&index);
}
Run Code Online (Sandbox Code Playgroud)
我不明白这条线有什么问题.是否需要进行类型转换?