Pound

课后习题第七章

牧云@^-^@ 提交于 2020-12-31 09:39:45
#1、编写一个程序读取输入,读到#字符停止,然后报告读取空格数,换行符数目以及所有的其它字符数目。 #include<stdio.h> int main(void) { int space = 0, line_break = 0, other = 0; char ch; while((ch = getchar()) != '#') { if(' ' == ch) { space++; } else if('\n' == ch) { line_break++; } else { other++; } } printf("space = %d\nline_break = %d\nother = %d\n", space, line_break, other); return 0; } 2.编写一个程序读取输入,读到#字符停止。程序要打印每个输入的字符以及对应的ASCII码(十进制)。一行打印8个字符。建议:使用字符计数和求模运算符(%)在每8个循环周期时打印一个换行符。 #include<stdio.h> int main() { char ch; int count = 0; printf("Please enter text(# to terminate):\n"); while((ch = getchar()) != '#') { printf("%c:%d ", ch, ch)

编写 unix和 windows的 Scala 脚本

老子叫甜甜 提交于 2020-10-07 03:26:18
编写 unix和 windows的 Scala 脚本 今天在看《Scala 编程》的时候看到附录了,里面提到了怎么在 unix 和 windows 下面编写 scala 脚本。 之前我也一直想用 scala 来在 unix 下写一些脚本,代替 shell,因为我对 shell 说实话不是很熟悉。 先直接给出一个可以正常的运行的例子把: #!/bin/sh exec scala "$0" "$@" !# 1.to(10).foreach(println) 上面的例子就是展示了在 unix 下面scala 脚本的例子,然后再 terminal 下面输入: sh -x untitled.scala 就可以运行这个文件了。 下面粘贴出书中的附录的内容: 如果你比较喜欢 Unix 的某些风味,通过在文件顶端前缀一个“制式”标志(pound bang),你 可以像运行 shell 脚本那样运行 Scala 脚本。例如,把以下内容输入文件 helloarg: #!/bin/sh exec scala "$0" "$@" !# // 对第一个参数打招呼 println("Hello, " + args(0) + "!") 头文字#!/bin/sh 必须在文件里最开头一行。一旦你设置了它的执行许可: $ chmod +x helloarg 你就可以像 shell 脚本那样运行 Scala 脚本,输入

Prime Path素数筛与BFS动态规划

筅森魡賤 提交于 2020-05-09 09:01:48
埃拉托斯特尼筛法(sieve of Eratosthenes ) 是古希腊数学家埃拉托斯特尼发明的计算素数的方法。对于求解不大于 n 的所有素数,我们先找出 sqrt(n) 内的 所有素数p1到pk ,其中 k = sqrt(n) ,依次剔除 Pi 的倍数,剩下的所有数都是素数。 具体操作如上述 图片所示。 C++实现 #include<iostream> #include<vector> using namespace std; int main() { int n; cin >> n; vector<bool> isprime(n + 5, true); vector<int> ans; for (int i = 2; i <= n; i++) { if (isprime[i]) { ans.push_back(i); for (int j = i * i; j <= n; j += i)isprime[j] = false; } } for (auto i : ans)cout << i << " "; cout << endl; return 0; } 整除问题 给定n,a求最大的k,使n!可以被a k整除但不能被a (k+1)整除。 输入描述 两个整数n(2<=n<=1000),a(2<=a<=1000) 输出描述 示例1 输入 555 12 输出 274

Amlogic电视盒子红外遥控适配笔记

天大地大妈咪最大 提交于 2020-04-19 23:03:08
前一阵做了个安卓6的固件, 在R3300L和Q7上跑的, 其他问题没有, 但是有用户反映原来的遥控器用不了了, 于是检查了一下遥控器配置, 顺便学习一下此类设备的红外遥控机制. 为了方便测试还上淘宝买了六个遥控器. Amlogic电视盒子的红外遥控配置 相关的配置文件有 /system/usr/keylayout/Generic.kl /system/usr/keylayout/Vendor_0001_Product_0001.kl /system/etc/remote.conf 或 /system/etc/remote1.conf Generic.kl文件 Generic key layout file for full alphabetic US English PC style external keyboards. This file is intentionally very generic and is intended to support a broad rang of keyboards. Do not edit the generic key layout to support a specific keyboard; instead, create a new key layout file with the required keyboard

how to use a reverse proxy to get around X-Frame-Options: SAMEORIGIN for iframe

时间秒杀一切 提交于 2019-11-30 09:40:31
问题 I am struggling to get around X-Frame-Options: SAMEORIGIN restriction on some pages so I can put them in an iframe. I understand that one can use a reverse proxy server to get around that, but I am not sure how. what I need is to create a touch screen interface for some lobby monitors that would have some external pages in an iframe. I do this to keep everything packed under the same ui. So ideally not all pages should use the reverse proxy. can anyone throw some light, with an example

Experts say the weaker pound is drawing investors to the UK tech sector

拈花ヽ惹草 提交于 2019-11-29 21:32:46
UK tech companies secured a record £5.5bn in foreign investment in the first seven months of this year, research shows. This was more than the amount invested per capita in the US tech sector in the same period, the Department of Digital, Culture, Media and Sport said. Experts say the weaker pound is drawing investors to the UK tech sector, which leads Europe in terms of funding. US and Asian firms invested most in the period, according to the study. Collectively, these two regions spent $3.7bn (£3.02bn; €3.31bn) in the first seven months of the year - overtaking the $2.9bn invested across the