我在接受采访时被问到这个问题
给定java中的假设列表,以及保持整数内容,也可以包含另一个相似类型的列表
例: [1,3,5,[6,7],8,9,10,[11,13,15,[16,17,[18,19]]],20]
输出应该是:
[1,3,5,6,7,8,9,10,11,13,15,16,17,18,19,20]
Run Code Online (Sandbox Code Playgroud)
我想的很容易!所以我带来了解决问题的递归解决方案!或不?
采访者说子列表可能会下降到任何深度,因此可能导致堆栈溢出错误!
我尝试提出非递归解决方案,但不能.谁能说出非递归解决方案可能是什么?
我发现以下代码添加了两个数字而不使用+运算符.
代码添加3和4:
printf("%d",printf("%*c%*c",3,' ',4,' '));
Run Code Online (Sandbox Code Playgroud)
现在printf()返回结果中的字符数,并%*c忽略它遇到的下一个字符.但是,我仍然无法理解这段代码.任何帮助,将不胜感激.
我正在尝试使用HTTPHandler 上传文件(多部分表单数据).
WebKit Boundary正在写入目标文件,从而破坏文件.
输入文件可以是任何类型的文件,包括文本,zip,apk等.
码:
public void handle(HttpExchange httpExchange) throws IOException {
URI uri = httpExchange.getRequestURI();
String httpReqMethod = httpExchange.getRequestMethod();
Headers headers = httpExchange.getRequestHeaders();
InputStream inputStrm = null;
FileOutputStream destFile = null;
String contentType = ((headers.get("Content-type") != null) ? (headers.get("Content-type").toString()) : (null));
httpExchange.getRequestURI().getQuery());
Map<String, String> queryParams = queryToMap(httpExchange.getRequestURI().getQuery());
Set<String> keys= headers.keySet();
Iterator<String> itr = keys.iterator();
while(itr.hasNext())
{
String key = (String)itr.next();
}
File file = new File(ACEConstants.WEB_SERVER_CTX_ROOT + uri.getPath()).getCanonicalFile();
String resource = uri.getPath().substring(
uri.getPath().indexOf(ACEConstants.WEB_SERVER_CTX_ROOT)+ACEConstants.WEB_SERVER_CTX_ROOT.length()+1);
if(httpReqMethod.equals(ACEConstants.HTTP_REQUEST_METHOD_POST) ) …Run Code Online (Sandbox Code Playgroud) 我正在使用Cloudflare 的自定义域名(https://thebotspeaks.com)托管我的git-hub pages网站(peps09791.github.io).要启用HTTPS,我已完成以下配置:
在我的_config.yaml文件中,我已相应地设置了URL密钥
网址:" https://peps0791.github.io "
在我的cloudFlare仪表板中,我启用了HTTPS重写选项以防止混合内容错误.
我还从CloudFlare启用了灵活SSL.
我没有启用默认的HTTPS重定向,因为网站突破了HTTPS.在HTTP上,它工作正常.
现在,当我尝试使用HTTPS访问我的网站时,我收到混合内容错误:
混合内容:" https://thebotspeaks.com/ " 页面是通过HTTPS加载的,但请求了一张不安全的图片" http://thebotspeaks.com/assets/images/bio-photo.jpg ".此内容也应通过HTTPS提供.
09:54:45.323(索引):1混合内容:" https://thebotspeaks.com/ " 页面是通过HTTPS加载的,但请求了一个不安全的样式表' http://thebotspeaks.com/assets/css/main .css '.此请求已被阻止; 内容必须通过HTTPS提供.
09:54:45.785(索引):1混合内容:" https://thebotspeaks.com/ " 页面是通过HTTPS加载的,但请求了一个不安全的脚本" http://thebotspeaks.com/assets/js/main .min.js '.此请求已被阻止; 内容必须通过HTTPS提供.
从控制台,我可以看到:
<script src="https://peps0791.github.io/assets/js/main.min.js"></script>
<link rel="stylesheet" href="https://peps0791.github.io/assets/css/main.css">
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我试图在Turbo C中运行这个程序,但无法破译输出.这%*c是什么意思?任何帮助,将不胜感激.
int dd,mm,yy;
printf("\n\tEnter day,month and year");
scanf("%d %*c %d %*c %d",&dd,&mm,&yy); // what does %*c mean ?
printf("\n\tThe date is : %d %d %d",dd,mm,yy);
Run Code Online (Sandbox Code Playgroud)
OUTPUT
Enter day, month and year 23
2
1991
3
5
The date is: 23 1991 5
Run Code Online (Sandbox Code Playgroud) 在C中,假设我需要从字符串中获取输入
int num,cost;
char *name[10];
printf("Enter your inputs [quantity item_of_name at cost]");
scanf("%d%*c%s%*c%*s%*c%d",&num,name[0],&cost);
printf("quantity of item: %d",num);
printf("the cost of item is: %d",cost);
printf("the name of item is: %d",name[0]);
Run Code Online (Sandbox Code Playgroud)
INPUT
12本书1本
OUTPUT
项目数量为:1
物品的成本是:12
项目名称为:book
现在我想在C++中做同样的事情.我不知道如何接近.gets()返回整个字符串.是否有任何我错过的特定函数?请帮忙.
我正在尝试实现Aleph在粉碎堆栈以获得乐趣和利润时给出的代码,以学习缓冲区溢出攻击的基础知识。
机器架构:Ubuntu 12.10 64 位
在 gcc 中使用 -m32 标志编译的程序
到目前为止,我已经设法使用汇编指令生成了一个 shell。下一步就是将那些指令转换成十六进制代码,这里我就遇到过这个问题。生成 shell 的汇编代码:
void main() {
__asm__(
"Start:"
"jmp CallCode\n\t"
"CallPop:"
"popl %esi\n\t"
"movl %esi,0x8(%esp)\n\t"
"xorl %eax,%eax\n\t"
"movb %al,0x7(%esp)\n\t"
"movl %eax,0xc(%esp)\n\t"
"movb $0xb,%al\n\t"
"movl %esi,%ebx\n\t"
"leal 0x8(%esp),%ecx\n\t"
"leal 0xc(%esp),%edx\n\t"
"int $0x80\n\t"
"xorl %ebx,%ebx\n\t"
"movl %ebx,%eax\n\t"
"inc %eax\n\t"
"int $0x80\n\t"
"CallCode:"
"call CallPop\n\t"
".string \"/bin/sh\"\n\t"
Run Code Online (Sandbox Code Playgroud)
); }
对应的十六进制代码为:
#include <sys/mman.h>
#include<stdio.h>
#define PAGE_SIZE 4096U
char shellcode[]= "\xeb\x24\x5e\x89\x74\x24\x08\x31\xc0\x88\x44\x24\x07\x89\x44\x24\x0c\xb0"
"\x0b\x89\xf3\x8d\x4c\x24\x08\x8d\x54\x24\x0c\xcd"
"\x80\x31\x89\xd8\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
void test_shellcode() {
int *ret;
// The …Run Code Online (Sandbox Code Playgroud) c ×3
java ×2
algorithm ×1
c++ ×1
cloudflare ×1
file-upload ×1
gcc ×1
github-pages ×1
hex ×1
httphandler ×1
https ×1
input ×1
linux ×1
list ×1
scanf ×1
shell ×1
ssl ×1
string ×1