- 1
- 2
- 3
- 4
- 5
int prev, next;
// next should not be equal to prev;
next = radnom(MAX);
if (next = prev)
next = random(MAX);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+125
int prev, next;
// next should not be equal to prev;
next = radnom(MAX);
if (next = prev)
next = random(MAX);
Просто передаю концепцию на общеславянском.
Будет интересно посчитать насколько всё-таки это говно уменьшает вероятность совпадения при разных MAX.
+134
class Slovo
{
public string Word;
public int Count;
public Slovo(string slovo, int kolichestvo)
{
Word = slovo;
Count = kolichestvo;
}
}
class Program
{
static void Main(string[] args)
{
string s = "Один два четыре восемь число один и два дают вместе восемь а один умножить на один будет один";
List<string> word = new List<string>();
List<int> count = new List<int>();
string[] word_collection = s.ToLower().Split(' ');
foreach (string str in word_collection) if (!word.Contains(str))
{
word.Add(str);
count.Add(1);
}
else count[word.IndexOf(str)]++;
List<Slovo> spisok = new List<Slovo>();
for (int i = 0; i < word.Count; i++) spisok.Add(new Slovo(word[i], count[i]));
spisok.Sort((a, b) => b.Count - a.Count);
foreach (Slovo slovo in spisok) Console.WriteLine(slovo.Word.PadRight(12) + slovo.Count.ToString());
Console.ReadKey();
}
}
Найти в строке самые частоповторяющиеся слова
+109
GLOBAL _start
SEGMENT .text
_start:
mov eax,4 ; N function=write
mov ebx,1 ; N handle=1 (stdout)
mov ecx, txt ; address of buf
mov edx,16 ; number of byte
int 80h
mov eax,3 ; N function=read
mov ebx,0 ; 0 handle=0 (stdin)
mov ecx, buf ; address of buf
mov edx,80 ; number of byte
int 80h
mov [len],eax ;save length buf
mov byte [buf+1],'!'
mov eax,4 ; N function=write
mov ebx,1 ; N handle=1 (stdout)
mov ecx, buf ; address of buf
mov edx,[len] ; number of byte
int 80h
mov eax,1 ; function=exit
int 80h
SEGMENT .data
buf times 80 db 0 ;
len dd 0
txt db 'Enter the text '
−99
private function onClick(e:MouseEvent):void
{
dispatchEvent(new MouseEvent(MouseEvent.CLICK, true, false))
}
Еще один кусочек очень полезного кода. (this для этого обработчика - MovieClip).
+15
#include <iostream>
#include <cxxabi.h>
#include <typeinfo>
int main(void)
{
uint8_t i = 63;
int status;
std::cout << i << std::endl;
char *realname = abi::__cxa_demangle(typeid(i).name(), 0, 0, &status);
std::cout << "Real type of uint8_t is: " << realname << std::endl;
delete (realname);
std::cout << (unsigned int)i << std::endl;
return 0;
}
...нативный 8bit-ый беззнаковый int.
+120
final TextField passwordField = UIFactory.createTextField(loginInfo, null);
passwordField.setWidth(textFieldWidthPx);
// Yes, they really want the password field to be shown openly.
// Don't blame me, I'm just following orders!
Безопасность такая безопасность.
+2
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct user_data{
char user_name[100];
char host_name[100];
}cuser;
char file_path[100000];
int sockfd;
void error(const char *msg){
perror(msg);
exit(0);
}
char s[128];vector<user_data> users;
int main(int argc, char *argv[]){
int portno, n;struct sockaddr_in serv_addr;
struct hostent *server;
char buffer[256];
static char file_name[256];
if (argc < 2) {
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
portno = atoi(argv[1]);
while(getchar()!='q'){
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
gethostname(s, 128);
server = gethostbyname(s);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
serv_addr.sin_port = htons(portno++);
if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
error("ERROR connecting");
bzero(buffer,256);
n = write(sockfd,buffer,strlen(buffer));
if (n < 0)
error("ERROR writing to socket");
bzero(buffer,256);
n = read(sockfd,buffer,255);
if (n < 0)
error("ERROR reading from socket");
int sf=0;
for(int i=0;i<=strlen(buffer)-1;i++){
if(buffer[i]=='@'){
sf=i;
}
if(sf==0){
cuser.user_name[i]=buffer[i];
} else {
cuser.host_name[i-sf]=buffer[i+1];
}
}
users.push_back(cuser);
cout << cuser.user_name << " hostname: " << cuser.host_name << endl;
printf("Enter file name:\n");
fgets(file_name,255,stdin);
n = write(sockfd,file_name,255);
if (n < 0)
error("ERROR writing to socket");
bzero(file_name,256);
n = read(sockfd,file_path,100000);
if (n < 0)
error("ERROR reading from socket");
printf("\n%s\n",file_path);
memset(file_path,'\0',100000);
close(sockfd);
}
printf("\n\tRegistered users\n");
for(int i=0; i < users.size(); i++)
{
cout << users[i].user_name << " hostname: " << users[i].host_name << endl;
}
close(sockfd);return 0;
}
Регистрация клиента на сервере
+97
SetLength(s,N);
SetLength(Y,N);
SetLength(U,N);
SetLength(Z,N);
SetLength(E,N);
for i:=0 to N do //какбэ на выход за границы даже не смотрим, не в этом суть
begin
SetLength(S[i],M);
SetLength(Y[i],M);
SetLength(U[i],M);
SetLength(Z[i],M);
SetLength(E[i],M);
end;
Переделывал чужой консольный проект под форму, не сразу понял, что происходит.
Так вот, Вы, наверное, думаете, что знаете, как задавать размер динамического массива? Нет, нихрена вы не знаете.
+148
if(type_file=='png'||type_file=='jpg'||type_file=='gif'||type_file=='jpeg'||type_file=='png')
+111
__flash unsigned char keyGenData[256*7]={
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1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(1<<4), //"4"
0*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+0*(1<<3)+1*(1<<4), //"5"
0*(1<<0)+1*(1<<1)+1*(1<<2)+1*(1<<3)+1*(1<<4),
0*(1<<0)+0*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
0*(1<<0)+1*(1<<1)+1*(1<<2)+0*(1<<3)+1*(1<<4),
1*(1<<0)+0*(1<<1)+0*(1<<2)+1*(1<<3)+1*(1<<4),
Нарыл в институте.
Забивают цифры для показывания на светодиодной панельке 5x7 (если присмотритесь, можете увидеть картинку, образуемую нулями). Такой простыни 96 КБ.