{}
BLACK FRIDAY SALE
Get Programiz PRO for LIFE at 60% off!
Claim My Discount
Sale ends in
BLACK FRIDAY
Save 60% on PRO: Sale Ends Soon!
Claim My Discount
run-icon
main.c
#include <stdio.h> #include <ctype.h> #include <stdint.h> #include <string.h> uint32_t getnummer(const char *str,int len) { uint32_t res=0; for(int i=0;i<len;i++) { const char el=str[i]; if(!isspace(el)) res = (res * (0x811C9DC5))^el; } return res; } int main(int argc,char **argv) { if(argc>1) { const char *id=argv[1]; printf("%u\n",getnummer(id,strlen(id))); return 0; } char *buf=NULL; size_t nr=0; int len; while((len=getline(&buf, &nr,stdin))>0) { if(buf[len-1]=='\n') --len; printf("%u\n",getnummer(buf,len)); } }
Output