Skip to content

Instantly share code, notes, and snippets.

View Eric-Bro's full-sized avatar

Eric Broska Eric-Bro

  • TrigenSoftware
  • Russia
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
int x=0, y=0, count=0, users=0;
int max=0;
scanf("%d%d", &count, &users);
--count;
int *stages = malloc(sizeof(*stages) * count);
- (void)imageView:(id)view didReceivedBundle:(NSBundle *)bundle
{
NSAlert *alert = [NSAlert alertWithMessageText: @""
defaultButton: @"Okay"
alternateButton: nil
otherButton: nil
informativeTextWithFormat: @""];
if (!bundle) {
/* The case should never be occurred */
@Eric-Bro
Eric-Bro / gist:3149836
Created July 20, 2012 09:21
[UI/NS]TextView old-school search
// textView - ваш NSTextView
// NSString *search_query - {глобальная переменная/член класса}
// строка, которую вам нужно найти
// NSRange result_range - {глобальная переменная/член класса}
// последние результаты поиска
// BOOL backwards_search - {глобальная переменная/член класса}
// поиск в обратном направлении?
//
/* "Главный" метод */
@Eric-Bro
Eric-Bro / gist:3149363
Created July 20, 2012 07:49
TBXML usage example
NSMutableARRAY *main_array = [[NSMutableArray alloc]init];
TBXML * tbxml = [[TBXML tbxmlWithURL:
[NSURL URLWithString: @"http://www.w3schools.com/xml/plant_catalog.xml"]] retain];
TBXMLElement *root = tbxml.rootXMLElement;
if (root) {
TBXMLElement *current_element = [TBXML childElementNamed: @"PLANT"
parentElement: root];
while (current_element != nil) {
TBXMLElement *entry = [TBXML childElementNamed: @"BOTANICAL"
@Eric-Bro
Eric-Bro / gist:2399691
Created April 16, 2012 16:08
Problem PA-1
input = $stdin.readline.split
n, m = input[0].to_i, input[1].to_i
$cmpts = Array.new(n){0}
def QprintEnergy(var)
var = $cmpts.inject(0){|sum, n| sum += n }
print var.to_s + "\n"
end
def Qparse_string()
@Eric-Bro
Eric-Bro / gist:2374228
Created April 13, 2012 06:01
Problem PA-3
substr = $stdin.readline
main = $stdin.readline
mlen = main.length-1
slen = substr.length-1
glob_count = 0
results = Array.new()
for i in 0...(mlen - slen+1) do
tmp_count = 0
field = 0
@Eric-Bro
Eric-Bro / Problem_PB-2.rb
Created April 12, 2012 09:44
Problem PB-2
Manager = Struct.new(:time, :cnt)
n = gets().to_i
times = $stdin.readline.split.each{|z| z = z.to_i}.sort!{|x,y| y <=> x}
managers = Array.new(3){|x| Manager.new(0,0)}
while (times.count > 0) do
managers.sort!{|x,y| x.time <=> y.time}[0].time += times.shift.to_i
managers[0].cnt += 1
end
managers.each{|x| print x.cnt.to_s + " "}
var i,k: integer;
a: array [1..10] of string;
s: string;
begin
readln(s);
k:=1;
for i:= 1 to length(s) do
if (s[i]<> ' ') then a[k]:= a[k] + s[i]
else if (a[k] <> '') then inc(k);
Var a:array[1..240] of string;
s:string; j,i:integer;
begin
readln(s);s:=s+' ';
j:=1;
for i:=1 to length(s)-1 do
if s[i]<>' ' then
a[j]:=a[j]+s[i]
else if s[i+1]<> ' ' then
j:=j+1;
@Eric-Bro
Eric-Bro / gist:1869319
Created February 20, 2012 13:54
Holy shit..
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
int is_digit(char c)
{
return (c >= '0' && c <= '9');
}