online programming practice

Alibabacloud.com offers a wide variety of articles about online programming practice, easily find your online programming practice information here online.

Java.nio.channels-based programming practice

= 0;while (true) {try {int select = Selector.select (), if (select > 0) {set Client Code Import Java.io.ioexception;import Java.io.unsupportedencodingexception;import Java.net.inetsocketaddress;import Java.nio.bytebuffer;import Java.nio.channels.closedchannelexception;import Java.nio.channels.selectionkey;import Java.nio.channels.selector;import Java.nio.channels.socketchannel;import Java.util.iterator;import Java.util.Set; Import Java.util.concurrent.timeunit;import Org.slf4j.logger;import Or

"Python Programming Quick Start" 6.7 Practice project Code

#-*-coding:utf-8-*-# The required output is as follows:# apples Alice Dogs# dranges Bob Cats# cherries Carol Moose# banana David Goose tabledata=[[' apples ',' oranges ',' cherries ',' banana '],[' Alice ',' Bob ',' Carol ',' David '],[' Dogs ',' Cats ',' Moose',' goose '] def printtable(data): colwidths=[0]*len(data)For y in range(len(data[0])):For x in range(len(data)): if colwidths[x] Len(data[x] [y ]): colwidths[x]=len(data[x] [y]) For y in range(len(data[0])):For x in ra

C + + Programming Practice Guide 1.10 two-dimensional array element transposition rewriting requirements implementation

;Next; } P=p->Next; } hpre->next=Max; Max->prior=Hpre; Max->next=Htail; Htail->prior=Max; Maxpre->next=Head; Head->prior=Maxpre; Head->next=Maxtail; Maxtail->prior=Head; P=dhead->Next; while(p) {Tail=p; P=p->Next; } P=dhead->Next; Min=p; Tpre=tail->Prior; while(p) {if(min->data>p->Data) {min=p; Minpre=p->Prior; Mintail=p->Next; } P=p->Next; } if(tpre==min)//node is adjacent to be processed separately {Minpre->next=tail; Tail->prior=Minpre; Tail->next=min; Min->prior=tail; Min->next=NULL; }

C + + Programming Practice Guide 1.12 Data linear transformations in arrays rewriting requirements implementation

Rewrite requirement 1: Replace array with pointer PA, PB, respectivelyRewrite requirement 2: Enter data element from keyboard any number of elements, enter 0 end#include #includeusing namespacestd;classdata{Double*pa,*PB; Doublemax,min; Doublenew_max,new_min; intlength; Public: DATA (DoubleA1[],DoubleXDoubleYintLen) { inti; Length=Len; PA=New Double[Len]; PB=New Double[Len]; for(i=0; i) Pa[i]=A1[i]; New_max=x; New_min=y; Max=min=pa[0]; for(i=0; i) {

C + + Programming Practice Guide 1.13 Finding composite rewriting requirements in natural number set implementation

Rewrite requirement 1: Implemented with single-linked listOverwrite Requirement 2: Delete the linked list node in turn in the destructor#include #includeusing namespacestd;structlinknode{intdata; Linknode*next;};classnoprime{friendstructLinknode; Linknode*Head; intN; Public: Noprime (intN1) {N=N1; } voidcreat (); intYesintx) { for(intI=2; i2; i++) if(x%i==0) return 1; return 0; } voidSearch (); voidprint () {Linknode* p=head->Next;

C + + Programming Practice Guide 1.9 statistics and substitution of keyword rewriting requirements in a string implementation

::findkeywords (stringKey[],stringSwapkey[],intLen) { intI=Len; stringtemp; Temp=p; intPos=temp.find (key[i-1]); while(i) { while(pos!=-1) {temp.replace (pos,key[i-1].length (), swapkey[i-1]); POS=temp.find (key[i-1]); } I--; } memset (P,0,sizeof(p)); strcpy (P,temp.c_str ());}voidwordnum::p rocess () {intword=1; intLen; Len=strlen (P); Char* r=New Char[Strlen (P)]; strcpy (R,P); for(intI=0; i) { if(((r[i]>='a'r[i]'Z')|| (r[i]>='A'r[i]'Z')) word) {C++; Word=0; }

C + + Programming Practice Guide 1.14 string cross-insert rewrite requirements implementation

#include #include #include using namespace Std;Class STRING{Char *str1;Char *str2;PublicSTRING (char* s1,char* S2){Str1=new Char[strlen (S1)];Str2=new Char[strlen (S2)];strcpy (STR1,S1);strcpy (STR2,S2);}void Insertinorder ();void process ();void print (){cout}};void STRING::p rocess (){int len1,len2,count=1;Char str[80];int i,j=0,k=0;Len1=strlen (STR1);Len2=strlen (STR2);int n=len2/len1;for (i=0;i{if (count% (n+1) ==0){Str[i]=str1[j++];count++;}else{Str[i]=str2[k++];count++;}}str[i]= ' + ';cout

Linux reliable/unreliable signal programming practice

]:~$ ulimit-acore File size (blocks,-c) unlimiteddata seg size (Kbytes,-D) unlimitedscheduling Priority (-e) 0file size (blocks,-f) unlimitedpending signals (-I ) 47131max locked memory (Kbytes, L) 64max Memory Size (Kbytes,-m) unlimitedopen files (-N) 1024pipe size (bytes,-p) 8POSIX message Queues (bytes,-Q) 819200real-time priority (-R) 0stack size (Kbytes,-s

Practice of multithreading Classic programming problems

Title One: Write two threads, one thread prints 1~52, another thread prints the letter a~z. The print order is 12a34b56c ..... 5152Z. Requires the use of communication between threads. Package test;Import Java.lang.Thread;Class printer{private int index = 1;Public synchronized void print (int n) {while (index%3==0) {try{Wait ();/* The Notify method that calls this object in other threads money, causing the current thread to wait */}catch (Exception e){E.printstacktrace ();}}System.out.print (ind

Hand in your homework-python programming (from Get started to practice)

The 4th chapter is the exercise in the Operation list 4.3.(1) Create a list that contains integers within the 3~30 that can be divisible by 2, and then use a for loop to hit the numbers in the list.(2) Create a list that contains the first 10 integers, and then use a for loop to print the list.(3) Use list resolution to generate a list that contains the first 10 integers of the cube.#注意里面的range噢 ~Specific answers:(1)(2) and (3), the first use of the list to parse, because relatively neat.Hand in

Java Threading and concurrency programming Practice----synchronizer (countdown latch)

{finalstaticintnthreads =3;publicstaticvoidmain (String[]args) {finalcountdownlatch startsignal=newcountdownlatch (1); finalcountdownlatchdonesignal= newcountdownlatch (nthreads); Runnabler=newrunnable () {@Overridepublic voidrun () {try{ System.out.println (Thread.CurrentThread (). GetName () + "Enter Wait"); startsignal.await (); System.out.println (Thread.CurrentThread (). GetName () + "Start performing tasks"); Thread.Sleep ($);d onesignal.countdown ();} catch (interruptedexceptione) {e.prin

"Python Core programming (third Edition)" 1th chapter Regular Expression practice answer __ storage

has been a programmer for many years, the first time to open a blog, welcome to fellow critics, comments.Recently obsessed with Python, after reading the Python Basics tutorial, and holding a "Python Core programming (third edition)" began to chew.After reading the first chapter, found a lot of very good exercises, I tried to do some, but on the internet can not find a very good answer. So decided to write their own write a record of their answers, ea

The practice of Shell programming is genuine (code example)

x+ matches 1 or more x strings, but matches the minimum possible number of times . * matches any character 0 or one time . + Match any character 1 or more times {m} matches exactly a specified string of M {M,n} matches a specified string below M + N [] matches the characters in [] [^] matches characters that do not match [] [0-9] match all numeric characters [A-z] matches all lowercase letters ^ characters that match the beginning of a character $ matches characters ending

Understanding and practice of the Google C + + programming specification

). However, this approach can reduce code readability and execution efficiency. If you want to include only the header files, do notThis alternative is good. Of course, the. cc file requires a defined portion of the class that is used anyway, and it will naturally contain several header files.Note: It is not dependent on the definition to be able to rely on the declaration.This rule works far beyond what we thought it would do (at least in my own experience). In a medium-sized project, the heade

Golden October online programming Competition No. 1: Little Girl count

Golden October online programming competition first question: Little Girl count questions details: [Golden October online programming Competition Rules] A little girl is counting from 1 to n with her left hand fingers. She starts counting from the thumb as 1. Then, the index finger is 2, the middle finger is 3, the ri

Introducing online programming and compiling sites

Online programming websitehttp://www.compileonline.com/It provides compilers, execution environments for various languages. The complexity of the installation configuration of the client can be greatly simplified. Real-time programming purposes;Of course, it is also a good idea to assume that you want to use the computing resources of these machines.Supported lan

Python programming data structure and algorithm practice _009

follows:if __name__=="__main__": #BSTHead1 = Node (9) Head1.left= Node (8) Head1.right= Node (10) Head1.left.left= Node (7) Head1.left.right= Node (9) Head1.right.left= Node (9) Head1.right.right= Node (11) Print(Is_bst_recur (HEAD1))#True Print(Is_bst_unrecur (HEAD1))#True #Not BSTHead2 = Node (9) Head2.left= Node (8) Head2.right= Node (1) Head2.left.left= Node (7) Head2.left.right= Node (9) Head2.right.left= Node (9) Head2.right.right= Node (11) Print(Is_bst_recur (HEAD2))#Fals

Basic knowledge of Python programming practice _004

Practice content: Create classes dynamically using type1 __author__='Orcsir'2 3 4 @classmethod5 defClass_method (CLS):6 Print("I am Class_method ...")7 8 9 @staticmethodTen defStatic_method (): One Print("I am Staticmethod ...") A - - def __init__(self, x, y): theself.x =x -SELF.Y =y - - + defFool (self): - Print("I am fool ....") + A at #type (name of the class, - #tuple of the parent class (for inheritance, can is empty), - #dictio

Basic knowledge of Python programming practice _007

() + - def_recv (self): + whileTrue: A Try: atdata = SELF.SOCK.RECV (1024) - except: - self.sock.close () - return - ifData: -Logging.info ("recv: {}". Format (Data.decode ())) in Else: - self.sock.close () to return + - defSend (self, data:str): the Self.sock.send (Data.encode ()) * $ defStop (self):Panax Notoginseng ifSelf.sock: - self.sock.close () the + A defMain (): theCC =chat

Until practice of Shell Programming basics

First, the grammaruntil [Condition] # and while on the contrary, when the condition condition is established, the loop is terminated, or the program segment that continues the loop does #执行内容done Second, practice Enter the user input parameters until the user enters "end" to end the loopUntilread-p "Plz input a Paramter": paramtest $param = "End" Doecho "$param" Done[Email protected]:~$./test.shPlz input a paramter:aaplz input a paramter:bb

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.