Three major language examples (Python,c/c++,java)

Source: Internet
Author: User
Tags stdin

Python3.5 Language Examples:

#coding = Utf-8ImportSYSdefsub_string (b): C=[0]*Len (b) forIinchRange (len (a)): forJinchRange (len (b)):ifSTR (a[i]). Find (str (B[J)))!=-1: C[j]= C[j] + 1 forKinchC:Print(k)if __name__=='__main__': N=Int (Sys.stdin.readline (). Strip ()) a=list () b=list () forIinchRange (N): A.append (Input ()) M=Int (Sys.stdin.readline (). Strip ()) forIinchRange (M): B.append (Input ()) sub_string (A, b)

python2.7 instances:

#!/usr/bin/env python#Coding=utf-8#Python uses 2.7, indents can use tab, 4 spaces, or 2 spaces, but only one can be selected, not a variety of mixing while1: A=[] s=raw_input ()#raw_input () do not have any information    ifs! ="":         forXinchs.split (): a.append (int (x))Printsum (a)Else:         Break

C Language Examples:

#include <stdio.h>int  main () {   int  A, b;     while (scanf ("%d%d", &a, &b)! = EOF)      printf ("%d \ n", A + b);}

C + + Language instance:

#include  usingnamespace  std; int Main () {    int  A, b;      while (Cin>> a >> b)     << A + b << Endl;     return 0 ;}

Java language instance:

//Package Main//be careful not to add the package name, or you will get an error. ImportJava.io.*;ImportJava.util.*;classTest {} Public classmain{ Public Static voidMain (String args[]) {Scanner cin=NewScanner (system.in); intA, B;  while(Cin.hasnextint ()) {a=Cin.nextint (); b=Cin.nextint (); System.out.println (A+b); }    }}

Three major language examples (Python,c/c++,java)

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.