1 / 10
Java или не Java?
val builder = StringBuilder();
builder.append("Hello");
builder.append("World");
print(builder.toString());
Java или не Java?
BufferedReader bufRead = new BufferedReader(new FileReader("reverseInt.txt"));
int x = Integer.valueOf(bufRead.readLine());
String reversed = new StringBuilder().append(Math.abs(x)).reverse().toString();
System.out.println((x < 0) ? Integer.parseInt(reversed) * -1 : Integer.parseInt(reversed));
bufRead.close();
Java или не Java?
ArrayList arr = new ArrayList();
for (var i = 0; i < input.Length; i += 2)
{
if (char.IsDigit(input[i]))
{
arr.Add((int) char.GetNumericValue(input[i]));
}
else
arr.Add(i);
}
Java или не Java?
export class AppComponent {
title = 'frontend';
constructor(private http: HttpClient) {
}
public clickFunction(): void {
this.http.get("/api/").subscribe(value => {
console.log(value);
})
}
}
Java или не Java?
void setup() {
fullScreen();
fill(0);
int w = (width / arr.length);
int h = (height-50) / arr.length;
int max = arr.length - 1;
}
Java или не Java?
@PutMapping(value = "/activate/id/{id}")
public UserProfileEntity activateUser(@PathVariable Long id) {
Optional user = userProfileService.findById(id);
UserProfileEntity entity = user.get();
entity.setIsBlocked((byte) 0);
return userProfileService.save(entity);
}
Java или не Java?
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
HttpServletRequest req = (HttpServletRequest) request;
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS");
res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Accept-Encoding, Accept-Language, Host, Referer, Connection, User-Agent, authorization, sw-useragent, sw-version");
if ( "OPTIONS".equals(req.getMethod()) ) {
res.setStatus(HttpServletResponse.SC_OK);
return;
}
filterChain.doFilter(request, response);
}
Java или не Java?
app.get('/quotes/:id', (request, response) => {
console.log("return quote with the ID: " + request.params.id);
db.get('SELECT * FROM Quotes WHERE rowid = ?', [request.params.id], (err, row) =>{
if(err) {
response.send("ERROR: " + err.message);
}
else {
response.send(row);
}
});
});
Java или не Java?
private fun convert2StringComponents(expression: String): Array {
val result = mutableListOf()
var prevIndex = 0
for (index in 0 until expression.length) {
when (expression[index]) {
'+', '-', '*', '/', '(', ')' -> {
if (!expression.substring(prevIndex, index).trim().isEmpty())
result.add(expression.substring(prevIndex, index))
result.add(expression[index].toString())
prevIndex = index + 1
}
}
}
if (prevIndex != expression.length)
result.add(expression.substring(prevIndex, expression.length))
return result.toTypedArray()
}
Java или не Java?
private static String encode(String word) {
var count = 0;
StringBuilder encodedWord = new StringBuilder();
word = word.toLowerCase();
String[] words = word.split("");
for (String word1 : words) {
for (String word2 : words) {
if (word1.equals(word2)) {
count++;
}
}
if (count > 1) encodedWord.append(")");
else encodedWord.append("(");
count = 0;
}
return encodedWord.toString();
}
Далее
0 из 10
Поздравляем с прохождением теста! А теперь предлагаем почитать статьи по программированию на Python на нашем сайте PythonTurbo!