int main() { freopen("palsquare.in","r",stdin); freopen("palsquare.out","w",stdout); bnumber *bn = (bnumber *)calloc(1,sizeof(bnumber)); bnumber *bp = (bnumber *)calloc(1,sizeof(bnumber)); int base,i; scanf("%d",&base); bn->base = bp->base = base; for(i = 1;i <= 300;i++) { setdata(i * i,bp); if(is_prlindormic(bp->data,bp->length)) { setdata(i,bn); printnum(bn->data,bn->length); printf(" "); printnum(bp->data,bp->length); printf("\n"); } } fclose(stdin); fclose(stdout); return 0; }
int main() { node* headptr;//保存第一个节点的地址 createlist(&headptr); insert(&headptr, 10, 2);//无效位置,会更正成末尾 insert(&headptr, 20, 0);//20,10 insert(&headptr, 30, 2);//20,10,30 insert(&headptr, 40, 1);//20,40,10,30 insert(&headptr, 50, 8);//无效位置,会更正成末尾 travel(headptr); printf("剩余%d个数据\n", listsize(headptr)); int n = find(headptr, 10); printf("查找10在第%d个节点\n", n); erase(&headptr, n); travel(headptr); n = find(headptr, 10); printf("查找10在第%d个节点\n", n); erase(&headptr, n); travel(headptr); setdata(headptr, 10, 100); setdata(headptr, 2, 99); travel(headptr); clear(&headptr); printf("剩余%d个数据\n", listsize(headptr)); return 0; }
/* * mips4k bootable image. */ static int mips4kboot(int fd, Fhdr *fp, ExecHdr *hp) { abort(); #ifdef unused USED(fd); fp->type = FMIPSB; switch(hp->e.h.amagic) { default: case 0407: /* some kind of mips */ settext(fp, (u32int)hp->e.h.mentry, (u32int)hp->e.h.text_start, hp->e.h.tsize, sizeof(struct mips4kexec)); setdata(fp, (u32int)hp->e.h.data_start, hp->e.h.dsize, fp->txtoff+hp->e.h.tsize, hp->e.h.bsize); break; case 0413: /* some kind of mips */ settext(fp, (u32int)hp->e.h.mentry, (u32int)hp->e.h.text_start, hp->e.h.tsize, 0); setdata(fp, (u32int)hp->e.h.data_start, hp->e.h.dsize, hp->e.h.tsize, hp->e.h.bsize); break; } setsym(fp, hp->e.h.nsyms, 0, hp->e.h.pcsize, hp->e.h.symptr); fp->hdrsz = 0; /* header stripped */ #endif return 1; }
static void d12_write_command(uint8_t cmd) { sethigh(A0_N); setlow(WR_N); setdata(cmd); sethigh(WR_N); }
static void wconfig(unsigned char config) { setcommand(COMMANDCONFIGW); setdata(config); }
void imc_send_direct(const imc_char_data *from, int channel, const char *argument, const char *to) { /* This sends a message out only to those MUDs directly connected to the one running this code. Added 12/26/98 to cut down on UCMM IMC network traffic -- Scion */ imc_packet out; char tobuf[IMC_MNAME_LENGTH]; imc_connect *c; if (imc_active<IA_UP) return; setdata(&out, from); strcpy(out.type, "chat"); /* emulate a broadcast packet so we don't have to add a imc_recv_direct() */ strcpy(out.to, "*@!direct!"); /* But we're not sending to *@* this time. */ imc_addkey(&out.data, "text", argument); imc_addkeyi(&out.data, "channel", channel); for (c=imc_connect_list; c; c=c->next) /* Go through the list of direct connections */ if (c->state==IMC_CONNECTED) { strcpy(tobuf, c->info->name); strcpy(out.to, "*@"); strcat(out.to, tobuf); imc_send(&out); /* And send them what they think is a broadcast packet. */ } imc_freedata(&out.data); }
void test(int system) { printf("init ...\n"); int mice = lmice_init(system); if (mice < 0) { ERROR; } OK; printf("%d mice found\n", mice); printf("creating result\n"); LMiceResult *result = lmice_result_new(); printf("read ... "); if (!lmice_read(result, true)) { ERROR; } OK; printf("count ... "); if (lmice_count() < 0) { ERROR; } OK; printf("lmice_count() == (return) lmcie_init() ..."); if (lmice_count() != mice) { printf("lmice_init returned %d and lmice_count retuned %d\n", mice, lmice_count()); ERROR; } OK; printf("clear ... (void)\n"); lmice_clear(); OK; setdata(result); printf("config_set ..."); if (lmice_config_set(result) == false) { ERROR; } OK; printf("config_save ..."); if (lmice_config_save(NULL) == false) { ERROR; } OK; printf("config_load ..."); if (lmice_config_load(NULL) == false) { ERROR; } OK; printf("uninit ... (void)\n"); lmice_uninit(false); OK; lmice_result_delete(result); }
void cmoorecoinsecret::setkey(const ckey& vchsecret) { assert(vchsecret.isvalid()); setdata(params().base58prefix(cchainparams::secret_key), vchsecret.begin(), vchsecret.size()); if (vchsecret.iscompressed()) vchdata.push_back(1); }
/* send an emote out on a channel */ void imc_send_emote(const imc_char_data *from, int channel, const char *argument, const char *to) { imc_packet out; char tobuf[IMC_MNAME_LENGTH]; if (imc_active<IA_UP) return; setdata(&out, from); strcpy(out.type, "emote"); imc_addkeyi(&out.data, "channel", channel); imc_addkey(&out.data, "text", argument); to=imc_getarg(to, tobuf, IMC_MNAME_LENGTH); while (tobuf[0]) { if (!strcmp(tobuf, "*") || !strcasecmp(tobuf, imc_name) || imc_find_reminfo(tobuf, 0)) { strcpy(out.to, "*@"); strcat(out.to, tobuf); imc_send(&out); } to=imc_getarg(to, tobuf, IMC_MNAME_LENGTH); } imc_freedata(&out.data); }
static int commonllp64(int, Fhdr *fp, ExecHdr *hp) { long pgsize; uvlong entry; hswal(&hp->e, sizeof(Exec)/sizeof(long), beswal); if(!(hp->e.magic & HDR_MAGIC)) return 0; /* * There can be more magic here if the * header ever needs more expansion. * For now just catch use of any of the * unused bits. */ if((hp->e.magic & ~DYN_MAGIC)>>16) return 0; entry = beswav(hp->e.hdr[0]); pgsize = mach->pgsize; settext(fp, entry, pgsize+fp->hdrsz, hp->e.text, fp->hdrsz); setdata(fp, _round(pgsize+fp->txtsz+fp->hdrsz, pgsize), hp->e.data, fp->txtsz+fp->hdrsz, hp->e.bss); setsym(fp, hp->e.syms, hp->e.spsz, hp->e.pcsz, fp->datoff+fp->datsz); if(hp->e.magic & DYN_MAGIC) { fp->txtaddr = 0; fp->dataddr = fp->txtsz; return 1; } commonboot(fp); return 1; }
int main() { freopen("dualpal.in","r",stdin); freopen("dualpal.out","w",stdout); int count,std; scanf("%d%d",&count,&std); while(count > 0) { std++; int i,flag = 0; for(i = 2;i <= 10;i++) { if(flag == 2) break; bnumber *bn = (bnumber *)calloc(1,sizeof(bnumber)); bn->base = i; setdata(std,bn); if(is_prlindormic(bn->data,bn->length)) flag++; free(bn); } if(flag == 2) { printf("%d\n",std); count--; } } fclose(stdin); fclose(stdout); }
static void d12_write_byte(uint8_t val) { setlow(A0_N); setlow(WR_N); setdata(val); sethigh(WR_N); }
static void setdevicedata(unsigned int id, unsigned char value) { if (id == PS2_MOUSE) setcommand(COMMANDDEV2WI); setdata(value); }
void MCImage::set_gif(uint1 *data, uint4 length) { if (data == nil) setrep(nil); else setdata(data, length); flags |= F_GIF; obj_id = 1; }
static void add_data(window w) { dialog_data *d; d = create (dialog_data); if (! d) return; d->hit = NOT_CHOSEN_YET; setdata(w, d); }
ssize_t iom_lcd_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { int i; if(length > BUFSZ) length = BUFSZ; copy_from_user(buf,gdata,length); printk("%s %d\n",buf,length); for(i=0; i<length; i++) setdata(buf[i]); return length; }
dataval(register expptr repp, register expptr valp) #endif { int i, nrep; ftnint elen; register Addrp p; if (parstate < INDATA) { frexpr(repp); goto ret; } if(repp == NULL) nrep = 1; else if (ISICON(repp) && repp->constblock.Const.ci >= 0) nrep = repp->constblock.Const.ci; else { err("invalid repetition count in DATA statement"); frexpr(repp); goto ret; } frexpr(repp); if( ! ISCONST(valp) ) { if (valp->tag == TADDR && valp->addrblock.uname_tag == UNAM_CONST) { /* kludge */ frexpr(valp->addrblock.memoffset); valp->tag = TCONST; } else { err("non-constant initializer"); goto ret; } } if(toomanyinit) goto ret; for(i = 0 ; i < nrep ; ++i) { p = nextdata(&elen); if(p == NULL) { err("too many initializers"); toomanyinit = YES; goto ret; } setdata((Addrp)p, (Constp)valp, elen); frexpr((expptr)p); } ret: frexpr(valp); }
void prefork(LinkList list, int flags) { LinkNode node; MUSTUSEHEAP("prefork"); for (node = firstnode(list); node; incnode(node)) { char *str, *str3; str = str3 = (char *)getdata(node); if ((*str == Inang || *str == Outang || *str == Equals) && str[1] == Inpar) { if (*str == Inang || *str == Outang) setdata(node, (void *) getproc(str)); /* <(...) or >(...) */ else setdata(node, (void *) getoutputfile(str)); /* =(...) */ if (!getdata(node)) return; } else { if (isset(SHFILEEXPANSION)) filesub((char **)getaddrdata(node), flags & 3); if (!(node = stringsubst(list, node, flags & 4))) return; } } for (node = firstnode(list); node; incnode(node)) { if (*(char *)getdata(node)) { remnulargs(getdata(node)); if (unset(IGNOREBRACES) && !(flags & 4)) while (hasbraces(getdata(node))) xpandbraces(list, &node); if (unset(SHFILEEXPANSION)) filesub((char **)getaddrdata(node), flags & 3); } else if (!(flags & 4)) uremnode(list, node); if (errflag) return; } }
/* * sparc bootable image */ static int sparcboot(int fd, Fhdr *fp, ExecHdr *hp) { USED(fd); fp->type = FSPARCB; settext(fp, hp->e.sentry, hp->e.sentry, hp->e.stext, sizeof(struct sparcexec)); setdata(fp, hp->e.sentry+hp->e.stext, hp->e.sdata, fp->txtoff+hp->e.stext, hp->e.sbss); setsym(fp, hp->e.ssyms, 0, hp->e.sdrsize, fp->datoff+hp->e.sdata); fp->hdrsz = 0; /* header stripped */ return 1; }
void*data_sine(ambixtest_presentationformat_t fmt, uint64_t frames, uint32_t channels, float32_t freq) { float64_t periods=freq/44100.; void*data=data_calloc(fmt, frames*channels); int64_t frame; for(frame=0; frame<frames; frame++) { int32_t chan; float64_t f=(float64_t)frame*periods; float64_t value=0.5*sin(f); for(chan=0; chan<channels; chan++) setdata(fmt, data, f*channels+chan, value); } return data; }
/* * next bootable image */ static int nextboot(int fd, Fhdr *fp, ExecHdr *hp) { USED(fd); fp->type = FNEXTB; settext(fp, hp->e.textc.vmaddr, hp->e.textc.vmaddr, hp->e.texts.size, hp->e.texts.offset); setdata(fp, hp->e.datac.vmaddr, hp->e.datas.size, hp->e.datas.offset, hp->e.bsss.size); setsym(fp, hp->e.symc.nsyms, hp->e.symc.spoff, hp->e.symc.pcoff, hp->e.symc.symoff); fp->hdrsz = 0; /* header stripped */ return 1; }
/* * Crack a normal a.out-type header */ static int adotout(int fd, Fhdr *fp, ExecHdr *hp) { long pgsize; USED(fd); pgsize = mach->pgsize; settext(fp, hp->e.entry, pgsize+sizeof(Exec), hp->e.text, sizeof(Exec)); setdata(fp, _round(pgsize+fp->txtsz+sizeof(Exec), pgsize), hp->e.data, fp->txtsz+sizeof(Exec), hp->e.bss); setsym(fp, hp->e.syms, hp->e.spsz, hp->e.pcsz, fp->datoff+fp->datsz); return 1; }
void*data_ramp(ambixtest_presentationformat_t fmt, uint64_t frames, uint32_t channels) { void*data=data_calloc(fmt, frames*channels); float64_t increment=1./(double)frames; float64_t value=0.; int64_t frame; for(frame=0; frame<frames; frame++) { int32_t chan; float32_t v32=value-0.5; value+=increment; for(chan=0; chan<channels; chan++) setdata(fmt, data, frame*channels+chan, v32); } return data; }
/* * mips bootable image. */ static int mipsboot(int fd, Fhdr *fp, ExecHdr *hp) { USED(fd); fp->type = FMIPSB; switch(hp->e.amagic) { default: case 0407: /* some kind of mips */ settext(fp, (u32int)hp->e.mentry, (u32int)hp->e.text_start, hp->e.tsize, sizeof(struct mipsexec)+4); setdata(fp, (u32int)hp->e.data_start, hp->e.dsize, fp->txtoff+hp->e.tsize, hp->e.bsize); break; case 0413: /* some kind of mips */ settext(fp, (u32int)hp->e.mentry, (u32int)hp->e.text_start, hp->e.tsize, 0); setdata(fp, (u32int)hp->e.data_start, hp->e.dsize, hp->e.tsize, hp->e.bsize); break; } setsym(fp, hp->e.nsyms, 0, hp->e.pcsize, hp->e.symptr); fp->hdrsz = 0; /* header stripped */ return 1; }
//fn to add new student record void newrec() { int no,res; printf("\n Rno:"); scanf("%d",&no); res=search(no); if(res!=-1) { printf("\n Record exists"); getch(); return; } setdata(no); fwrite(&rec,sizeof(rec),1,fa); }
/* beep a remote player */ void imc_send_beep(const imc_char_data *from, const char *to) { imc_packet out; if (imc_active<IA_UP) return; if (!strcmp(imc_mudof(to), "*")) return; /* don't let them do this */ setdata(&out, from); strcpy(out.type, "beep"); imc_sncpy(out.to, to, IMC_NAME_LENGTH); imc_send(&out); imc_freedata(&out.data); }
/* send a whois-request to a remote mud */ void imc_send_whois(const imc_char_data *from, const char *to) { imc_packet out; if (imc_active<IA_UP) return; if (strchr(to, '@')) return; setdata(&out, from); sprintf(out.to, "%s@*", to); strcpy(out.type, "whois"); imc_send(&out); imc_freedata(&out.data); }
/* * (Free|Net)BSD ARM header. */ static int armdotout(int fd, Fhdr *fp, ExecHdr *hp) { uvlong kbase; USED(fd); settext(fp, hp->e.entry, sizeof(Exec), hp->e.text, sizeof(Exec)); setdata(fp, fp->txtsz, hp->e.data, fp->txtsz, hp->e.bss); setsym(fp, hp->e.syms, hp->e.spsz, hp->e.pcsz, fp->datoff+fp->datsz); kbase = 0xF0000000; if ((fp->entry & kbase) == kbase) { /* Boot image */ fp->txtaddr = kbase+sizeof(Exec); fp->name = "ARM *BSD boot image"; fp->hdrsz = 0; /* header stripped */ fp->dataddr = kbase+fp->txtsz; } return 1; }
/* send a who-request to a remote mud */ void imc_send_who(const imc_char_data *from, const char *to, const char *type) { imc_packet out; if (imc_active<IA_UP) return; if (!strcmp(imc_mudof(to), "*")) return; /* don't let them do this */ setdata(&out, from); sprintf(out.to, "*@%s", to); strcpy(out.type, "who"); imc_addkey(&out.data, "type", type); imc_send(&out); imc_freedata(&out.data); }
static int commonllp64(int unused, Fhdr *fp, ExecHdr *hp) { int32 pgsize; uvlong entry; USED(unused); hswal(&hp->e, sizeof(Exec)/sizeof(int32), beswal); if(!(hp->e.exechdr.magic & HDR_MAGIC)) return 0; /* * There can be more magic here if the * header ever needs more expansion. * For now just catch use of any of the * unused bits. */ if((hp->e.exechdr.magic & ~DYN_MAGIC)>>16) return 0; union { char *p; uvlong *v; } u; u.p = (char*)&hp->e.exechdr; entry = beswav(*u.v); pgsize = mach->pgsize; settext(fp, entry, pgsize+fp->hdrsz, hp->e.exechdr.text, fp->hdrsz); setdata(fp, _round(pgsize+fp->txtsz+fp->hdrsz, pgsize), hp->e.exechdr.data, fp->txtsz+fp->hdrsz, hp->e.exechdr.bss); setsym(fp, fp->datoff+fp->datsz, hp->e.exechdr.syms, 0, hp->e.exechdr.spsz, 0, hp->e.exechdr.pcsz); if(hp->e.exechdr.magic & DYN_MAGIC) { fp->txtaddr = 0; fp->dataddr = fp->txtsz; return 1; } commonboot(fp); return 1; }