Home > Software engineering >  How to efficient statistical a range by the number of discrete data
How to efficient statistical a range by the number of discrete data

Time:09-23

Within a range of random distribution with a large number of discrete data, how can effective number of statistical data, the great god give a idea

CodePudding user response:

Fyi:
 # include & lt; Stdio. H> 
# include & lt; String. H>
Char [] s1="delete";
Char [] s2="select";
Unsigned char n [256]={0};
Char r [257];
Int I, L, o=0;
Void main () {
L=strlen (s1); for (i=0; iL=strlen (s2); for (i=0; iL=0;
For (o=1; O<=256; O++) {
For (I=0; i<256; I++) {
If (o==n [I]) {
R [L++]=I;
break;
}
}
If (i>=256) break;
}
R [L]=0;
Printf ("] [% s \ n ", r);
}
///deltsc

CodePudding user response:

Again for reference:
//randomly generated 100000000 scope for [0 ~ 2 32 minus 1] data, 
//and then let the user to input a data, determine the user input data is not included in the randomly generated data,
//requirements: when the user input is completed, must be completed within 1 milliseconds (one over one thousand of a second),
# include & lt; Stdio. H>
# include & lt; stdlib.h>
# include & lt; Time. H>
# include & lt; The malloc. H>
Long int I;
Unsigned long ul;
Unsigned long * d;
Unsigned long ulrand (void) {
Return (
(((unsigned long) rand () & lt; <24) & amp; 0 xff000000ul)
| (((unsigned long) rand () & lt; <12) & amp; 0 x00fff000ul)
| (((unsigned long) rand ()) & amp; 0 x00000ffful));
}
Void main () {
D=(unsigned long *) calloc (1 & lt; <(32-5), sizeof (unsigned long));
If (NULL==d) {
Printf (" Can not calloc (% d, % d). \ n ", 1 & lt; <(32-5), sizeof (unsigned long));
return;
}
srand(time(NULL));
for (i=0; i<100000000; I++) {
While (1) {
Ul=ulrand ();
If (0==(d (ul> & gt; 5) & amp; (1 lu & lt; <(32) ul %))) {
D (ul> & gt; 5) |=1 & lt; <(ul % 32);
break;
}
}
If (0==I % 1000000) printf (" % % 9 d, 10 lu \ n ", I, ul);
}
While (1) {
Printf (" \ nInput a number: ");
The fflush (stdout);
The rewind (stdin);
If (1==the scanf (" % lu ", & amp; Ul)) break;
}
If (d (ul> & gt; 5) & amp; (1 & lt; <(32) ul %)) printf (" Include. \ n ");
The else printf (" Not include. \ n ");
Free (d);
}
//000000000213468 533
//001000000246805 973
//002000000384079 964
//003000000188232 874
//004000000120697 784
//005000000405838 287
//006000000380081 245
//007000000158042 671
//008000000311931 368
//009000000, 251096899
//010000000349239 701
//011000000336323 844
//012000000219846 708
//013000000187478 195
//014000000111631 457
//015000000192301 519
//016000000171332 861
//017000000292278 240
//018000000, 694854106
//019000000, 273255526
//020000000, 398518467
//021000000327756 812
//022000000150289 424
//023000000150241 936
//024000000177380 660
//025000000366842 116
//026000000325869 879
//027000000129184 024
//028000000107990 028
//029000000, 242094712
//030000000378344 297
//031000000259365 925
//032000000, 962754138
//033000000205075 654
//034000000408452 879
//035000000, 489250842
//036000000, 611455230
//037000000, 277350616
//038000000159410 795
//039000000322173 662
//040000000229446 877
//041000000254280 575
//042000000250145 642
//043000000237773 252
//044000000, 635555963
//045000000267538 666
//046000000425690 312
//047000000267755 514
//048000000126320 296
//049000000317516 920
//050000000143265 210
//051000000, 196156173
//052000000247825 669
//053000000253750 977
//054000000118829 949
//055000000320826 434
//056000000226336 265
//057000000, 313302924
//058000000363264 578
//059000000115892 716
//060000000298304 230
//061000000125204 837
//062000000129076 720
//063000000, 242249250
//064000000399999 961
//065000000, 431166416
//066000000136947 236
//067000000141387 330
//068000000214784 481
//069000000324175 409
//070000000415065 163
//071000000142449 573
//072000000249600 232
//073000000131783 455
//074000000372170 478
//075000000306111 466
//076000000, 408557403
//077000000372586 955
//078000000380652 651
//079000000378160 154
//080000000332440 047
//081000000140976 868
//082000000, 471838899
//083000000214198 260
//084000000378081 738
//085000000343027 738
//086000000115808 750
//087000000278578 638
//088000000, 85604584
//089000000270078 162
//090000000, 584840269
//091000000385577 719
//092000000282653 537
//093000000, 797877025
//094000000224017 755
//095000000178038 685
//096000000281548 567
//097000000, 489107494
//098000000, 911680090
//099000000367777 147
//
//Input a number: 3677777147
//Include.
  • Related