c++中Input terminates by EOFtouch input是什么么意思?

数位DP,一句话概括,就是在一个给定区间内求出满足某中奇葩条件的数字个数,这真是奇葩题目,但是总体写起来又有一定规律性。
主要可以分为以下几个步骤:
确定主体框架,确定一个大方向,想想该如何设计状态;
下面基本就是模板,直接DFS就行了,一位一位处理,这也是他叫按位DP的原因。
数位DP代码一般都很短,不过效率挺好,解决一些竞赛中出现的问题非常有用 。
如果看了这部分 ,你感觉还是不会的话,(这是当然啊,狂汗~~),那么请继续往下看。
下面用几个例子来说明一下,具体注释都附在代码内:
PS:我是菜狗,这些都是很水的数位DP,求大神勿喷~~
————————————————————— ——华丽的分割线—————————————————————
Problem 1160 - 科协的数字游戏I
Time Limit: 1000MS&&&&& Memory Limit: 65536KB&&&&&
Difficulty:&&&&
Total Submit: 181&&&& Accepted: 29&&&&
Special Judge: No&
Description
科协里最近很流行数字游戏。某人命名了一种不降数,这种数字必须满足从左到右各位数字成大于等于的关系,如123,446。现在大家决定玩一个游戏,指定一个整数闭区间[a,b],问这个区间内有多少个不降数。
题目有多组测试数据。每组只含2个数字a, b (1 &= a, b &= 2^31)。
每行给出一个测试数据的答案,即[a, b]之间有多少阶梯数。
Sample Input
Sample Output
/********************************************************************
* Problem:科协的数字游戏2
* source:XDOJ
* author:sgx
*********************************************************************/
#include&cstdio&
#include&cstring&
#include&algorithm&
#define LL long long
const int N=25;
int digit[N];
LL dp[N][N];
LL dfs(int pos,int statu,int limit)
int i,end,s;
if(pos==-1)
if(!limit&&dp[pos][statu]!=-1)
return dp[pos][statu];
end=limit?digit[pos]:9;
for(i=i&=i++)
res+=dfs(pos-1,i,limit&&i==end);
if(!limit)
dp[pos][statu]=
LL calc(LL n)
int len=0;
memset(dp,-1,sizeof(dp));
digit[len++]=n%10;
return dfs(len-1,0,1);
int main()
while(scanf(&%lld %lld&,&a,&b)!=EOF)
printf(&%lld\n&,calc(b)-calc(a-1));
————————————————————————————————————分割线—————————————————————————————————————
Problem 1161 - 科协的数字游戏II
Time Limit: 1000MS&&&&&
Memory Limit: 65536KB&&&&&
Difficulty:&&&&
Total Submit: 108&&&&
Accepted: 13&&&&
Special Judge: No&
Description
由于科协里最近真的很流行数字游戏。(= =!汗一个)某人又命名了一种取模数,这种数字必须满足各位数字之和 mod N为0。现在大家又要玩游戏了,指定一个整数闭区间[a,b],问这个区间内有多少个取模数。
题目有多组测试数据。每组只含3个数字a, b, n (1 &= a, b &= 2^31,1 &= n & 100)。
每个测试用例输出一行,表示各位数字和 mod N为0 的数的个数。
Sample Input
Sample Output
/********************************************************************
* Problem:科协的数字游戏2
* source:XDOJ
* 分析:记忆化搜索部分,pre表示前面各位数字之和对该数取模的结果
* author:sgx
*********************************************************************/
#include &iostream&
#include &cstdlib&
#include &cstring&
#include &cstdio&
typedef long long LL;
const int maxn=100+5;
int dp[maxn][105];
int digit[maxn];
int mod,l,r;
int DFS(int pos,int pre,bool limit)
if(pos==-1)
return pre==0;
if(!limit&&dp[pos][pre]!=-1)
return dp[pos][pre];
LL res=0,end=limit?digit[pos]:9;
for(int i=0;i&=i++)
int new_pre=(pre+i)%
res+=DFS(pos-1,new_pre,limit&&i==end);
if(!limit)
dp[pos][pre]=
LL solve(int n)
int len=0;
digit[len++]=n%10;
return DFS(len-1,0,true);
int main()
while(scanf(&%d%d%d&,&l,&r,&mod)!=EOF)
memset(dp,-1,sizeof(dp));
printf(&%lld\n&,solve(r)-solve(l-1));
————————————分割线————————
HDU3052--B-number
Time Limit:
MS (Java/Others)&&& Memory Limit:
K (Java/Others)
Total Submission(s): 1556&&& Accepted Submission(s): 852
Problem Description
A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string &13& and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your task is to calculate how many wqb-numbers
from 1 to n for a given integer n.
Process till EOF. In each line, there is one positive integer n(1 &= n &= ).
Print each answer in a single line.
Sample Input
Sample Output
/**************************************************************
* 题意:求[1,n]内有多少个数字,该数字有13,且能被13整除 n&=10^9
即要满足x % 13 = 0;x=pre*10^pos+
(pos代表处理到当前的位数,next代表正在处理的位置上面的数字)
(pre*10^pos + next) % 13 = 0,pre是之前确定的部分;
需要的参数为pre , pos ,状态用status表示
status==2记录pre拥有&13&,status==1是表示没有出现13,但是首位是1;
status=0表示没有13;
* Author:sgx
*************************************************************************/
#include &iostream&
#include &cstdlib&
#include &cstring&
#include &cstdio&
typedef long long LL;
const int maxn=100+5;
int dp[10][13][3];
int digit[10];
int DFS(int pos,int status,int pre,bool limit)
if(pos==-1)
return status==2&&pre==0;
if(!limit&&dp[pos][pre][status]!=-1)
return dp[pos][pre][status];
int end=limit?digit[pos]:9;
for(int i=0;i&=i++)
int new_pre=(pre*10+i)%13;
int new_status=
/*准备计算出下一阶段中新的状态status*/
if(status==0&&i==1)
new_status=1;/*原来没有出现13但是当前位是1,所以属于状态1对应的情况,故更新新状态为1;*/
if(status==1&&i==1)
new_status=1;/*解释方法同上*/
else if(status==1&&i!=3)
new_status=0;
if(status==1&&i==3)
new_status=2;
res+=DFS(pos-1,new_status,new_pre,limit&&i==end);
/*//limit==true则说明有限制,即所有可能并没有被全部记录,故此时记入dp数组 */
//limit==false则说明之后的分支状态已经搜索完全
if(!limit)
dp[pos][pre][status]=
LL solve(int n)
int len=0;
digit[len++]=n%10;
return DFS(len-1,0,0,true);
int main()
while(scanf(&%lld&,&n)!=EOF)
memset(dp,-1,sizeof(dp));
printf(&%lld\n&,solve(n));
HDU3555----BombTime Limit:
MS (Java/Others)&&& Memory Limit: 36 K (Java/Others)
Total Submission(s): 4594&&& Accepted Submission(s): 1601
Problem Description
The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current number sequence includes the sub-sequence &49&, the power of the blast
would add one point.
Now the counter-terrorist knows the number N. They want to know the final points of the power. Can you help them?
The first line of input consists of an integer T (1 &= T &= 10000), indicating the number of test cases. For each test case, there will be an integer N (1 &= N &= 2^63-1) as the description.
The input terminates by end of file marker.
For each test case, output an integer indicating the final points of the power.
Sample Input
Sample Output
/******************************************************************
* PS:网上大神的文章真的太神了,改不了,贴过来
* 附个链接:http://blog.csdn.net/whyorwhnt/article/details/8764955
*******************************************************************/
#include &cstdio&
#include &cstring&
int bit[25];
__int64 dp[25][3];
//dp[i][0]表示长度为i,没有49
//dp[i][1]表示长度为i,没有49但前一位为4
//dp[i][2]表示长度为i,包括49的个数
/*limit表示是否有上限,比如n=1234,现在转移到12,如果下一位选3,那么再下一位就有上限,
上限为4,如果不选3,那么下一位就没限制,最高位9,转移能保证转移到数比n小*/
__int64 Dfs (int pos,int s,bool limit) //s为之前数字的状态
if (pos==-1)
return s==2;
if (limit==false && ~dp[pos][s])
return dp[pos][s];
int i ,end=limit?bit[pos]:9;
__int64 ans=0;
for (i=0;i&=i++)
int nows=s;
if(s==0 && i==4)
if(s==1 && i!=9) //前一位为4
if(s==1 && i==4)
if(s==1 && i==9) //49
ans+=Dfs(pos-1 , nows , limit && i==end);
//limit==true则说明有限制,即所有可能并没有被全部记录,故此时记入dp数组
//limit==false则说明之后的分支状态已经搜索完全
return limit?ans:dp[pos][s]=
int main ()
memset(dp,-1,sizeof(dp));
scanf(&%d&,&T);
while (T--)
scanf(&%I64d&,&n);
int len=0;
bit[len++]=n%10;
printf(&%I64d\n&,Dfs(len-1,0,1));
HDU2089--不要62
Time Limit:
MS (Java/Others)&&& Memory Limit:
K (Java/Others)
Total Submission(s): 13687&&& Accepted Submission(s): 4402
Problem Description
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
输入的都是整数对n、m(0&n≤m&1000000),如果遇到都是0的整数对,则输入结束。
对于每个整数对,输出一个不含有不吉利数字的统计个数,该数值占一行位置。
Sample Input
Sample Output
/********************************************************************
* Problem:HDU2089-不要62
* source:HDU
* 分析:记忆化搜索部分,i==4时要及时continue掉,不然无限WA;
* author:sgx
*********************************************************************/
#include &iostream&
#include &cstdlib&
#include &cstring&
#include &cstdio&
typedef long long LL;
const int maxn=100+5;
int dp[maxn][3];
int digit[maxn];
//dp[i][0]表示长度为i,没有62
//dp[i][1]表示长度为i,没有62但前一位为6
//dp[i][2]表示长度为i,包括62的个数
int DFS(int pos,int status,bool limit)
if(pos==-1)
return status==2;
if(!limit&&dp[pos][status]!=-1)
return dp[pos][status];
LL res=0,end=limit?digit[pos]:9;
for(int i=0;i&=i++)
int new_status=
new_status=2;
else if(status==0&&i==6)
new_status=1;
else if(status==1&&i==6)
new_status=1;
else if(status==1&&i!=2)
new_status=0;
else if(status==1&&i==2)
new_status=2;
res+=DFS(pos-1,new_status,limit&&i==end);
if(!limit)
dp[pos][status]=
LL solve(int n)
int len=0;
digit[len++]=n%10;
return DFS(len-1,0,true);
int main()
while(scanf(&%d%d&,&n,&m)!=EOF&&(n+m))
memset(dp,-1,sizeof(dp));
printf(&%lld\n&,m-n+1-solve(m)+solve(n-1));
HDU4734F(x)
Time Limit:
MS (Java/Others)&&& Memory Limit:
K (Java/Others)
Total Submission(s): 485&&& Accepted Submission(s): 179
Problem Description
For a decimal number x with n digits (AnAn-1An-2 ... A2A1),
we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2
* 2 + A1 * 1. Now you are given two numbers A and B, please calculate how many numbers are there between 0 and B, inclusive, whose weight is no more than F(A).
The first line has a number T (T &= 10000) , indicating the number of test cases.
For each test case, there are two numbers A and B (0 &= A,B & 109)
For every case,you should output &Case #t: & at first, without quotes. The
t is the case number starting from 1. Then output the answer.
Sample Input
Sample Output
Case #1: 1
Case #2: 2
Case #3: 13
#include &cstdio&
#include &cstring&
#include &iostream&
#include &cstdlib&
#include &algorithm&
const int maxn=300;
const int maxm=6000;
int dp[maxn][maxm];
int a[maxn];
int DFS(int pos,int cur,int limit)
int i,ed,s,ans=0;
if(pos==-1)
return cur&=0;
if(!limit&&dp[pos][cur]!=-1)
return dp[pos][cur];
ed=limit?a[pos]:9;
for(i=0;i&=i++)
s=cur-i*(1&&pos);
ans+=DFS(pos-1,s,limit&&i==ed);
if(!limit&&dp[pos][cur]==-1)
dp[pos][cur]=
int transfer(int n)
int res=0,m=1;
res+=(n%10)*m;
int solve(int n,int m)
int st=-1;
a[++st]=m%10;
int res=DFS(st,transfer(n),1);
int main()
int test,n,m;
scanf(&%d&,&test);
memset(dp,-1,sizeof(dp));
for(int ii=1;ii&=ii++)
scanf(&%d%d&,&n,&m);
printf(&Case #%d: %d\n&,ii,solve(n,m));
Description
windy定义了一种windy数。
不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。
windy想知道,在A和B之间,包括A和B,总共有多少个windy数?
包含两个整数,A B。
满足 1 &= A &= B &=
包含一个整数:闭区间[A,B]上windy数的个数。
Sample Input
Sample Output
纪念UESTC首A,
艰难AC。。。。
/*******************************************************************
* problem:windy数
* source:UESTC1307
* author:sgx
********************************************************************/
#include &iostream&
#include &cstdio&
#include &cstring&
#include &cmath&
const int maxn=20;
typedef long long LL;
LL dp[maxn][11];
LL digit[maxn];
LL DFS(int pos,int pre,bool limit,bool first_place)//first_place判断前导0
if(pos==-1)
return first_place==0;
if(!limit&&dp[pos][pre]!=-1&&first_place==false)
return dp[pos][pre];
int end=limit?digit[pos]:9;
for(int i=0;i&=i++)
if(first_place!=0)
ans+=DFS(pos-1,i,limit&&i==end,first_place&&i==0);
else if(abs(i-pre)&=2)
ans+=DFS(pos-1,i,limit&&i==end,first_place);
if(!limit&&first_place==false)
dp[pos][pre]=
LL solve(LL n)
digit[len++]=n%10;
return DFS(len-1,0,true,true);
int main()
while(scanf(&%lld%lld&,&l,&r)!=EOF)
memset(dp,-1,sizeof(dp));
LL ans=solve(r)-solve(l-1);
printf(&%lld\n&,ans);
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:76670次
积分:2734
积分:2734
排名:第5773名
原创:192篇
转载:19篇
评论:23条
(3)(2)(13)(19)(2)(21)(14)(60)(77)PrintWriter (Java Platform SE 7 )
JavaScript is disabled on your browser.
Class PrintWriter
java.io.PrintWriter
All Implemented Interfaces:
public class PrintWriter
Prints formatted representations of objects to a text-output stream.
class implements all of the print methods found in .
It does not contain methods for writing raw bytes, for which
a program should use unencoded byte streams.
Unlike the
class, if automatic flushing is enabled
it will be done only when one of the println, printf, or
format methods is invoked, rather than whenever a newline character
happens to be output.
These methods use the platform's own notion of line
separator rather than the newline character.
Methods in this class never throw I/O exceptions, although some of its
constructors may.
The client may inquire as to whether any errors have
occurred by invoking .
Field Summary
Modifier and Type
Field and Description
The underlying character-output stream of this
PrintWriter.
Fields inherited from class&java.io.
Constructor Summary
Constructors&
Constructor and Description
Creates a new PrintWriter, without automatic line flushing, with the
specified file.
Creates a new PrintWriter, without automatic line flushing, with the
specified file and charset.
Creates a new PrintWriter, without automatic line flushing, from an
existing OutputStream.
boolean&autoFlush)
Creates a new PrintWriter from an existing OutputStream.
(&fileName)
Creates a new PrintWriter, without automatic line flushing, with the
specified file name.
(&fileName,
Creates a new PrintWriter, without automatic line flushing, with the
specified file name and charset.
Creates a new PrintWriter, without automatic line flushing.
boolean&autoFlush)
Creates a new PrintWriter.
Method Summary
Modifier and Type
Method and Description
Appends the specified character to this writer.
Appends the specified character sequence to this writer.
int&start,
Appends a subsequence of the specified character sequence to this writer.
Flushes the stream if it's not closed and checks its error state.
protected void
Clears the error state of this stream.
Closes the stream and releases any system resources associated
Flushes the stream.
Writes a formatted string to this writer using the specified format
string and arguments.
Writes a formatted string to this writer using the specified format
string and arguments.
(boolean&b)
Prints a boolean value.
Prints a character.
(char[]&s)
Prints an array of characters.
(double&d)
Prints a double-precision floating-point number.
Prints a floating-point number.
Prints an integer.
Prints a long integer.
Prints an object.
Prints a string.
A convenience method to write a formatted string to this writer using
the specified format string and arguments.
A convenience method to write a formatted string to this writer using
the specified format string and arguments.
Terminates the current line by writing the line separator string.
(boolean&x)
Prints a boolean value and then terminates the line.
Prints a character and then terminates the line.
(char[]&x)
Prints an array of characters and then terminates the line.
(double&x)
Prints a double-precision floating-point number and then terminates the
Prints a floating-point number and then terminates the line.
Prints an integer and then terminates the line.
Prints a long integer and then terminates the line.
Prints an Object and then terminates the line.
Prints a String and then terminates the line.
protected void
Indicates that an error has occurred.
(char[]&buf)
Writes an array of characters.
(char[]&buf,
Writes A Portion of an array of characters.
Writes a single character.
Writes a string.
Writes a portion of a string.
Methods inherited from class&java.lang.
, , , , , , , , , ,
Field Detail
protected& out
The underlying character-output stream of this
PrintWriter.
Constructor Detail
PrintWriter
public&PrintWriter(&out)
Creates a new PrintWriter, without automatic line flushing.
Parameters:out - A character-output stream
PrintWriter
public&PrintWriter(&out,
boolean&autoFlush)
Creates a new PrintWriter.
Parameters:out - A character-output streamautoFlush - A if true, the println,
printf, or format methods will
flush the output buffer
PrintWriter
public&PrintWriter(&out)
Creates a new PrintWriter, without automatic line flushing, from an
existing OutputStream.
This convenience constructor creates the
necessary intermediate OutputStreamWriter, which will convert characters
into bytes using the default character encoding.
Parameters:out - An output streamSee Also:
PrintWriter
public&PrintWriter(&out,
boolean&autoFlush)
Creates a new PrintWriter from an existing OutputStream.
convenience constructor creates the necessary intermediate
OutputStreamWriter, which will convert characters into bytes using the
default character encoding.
Parameters:out - An output streamautoFlush - A if true, the println,
printf, or format methods will
flush the output bufferSee Also:
PrintWriter
public&PrintWriter(&fileName)
Creates a new PrintWriter, without automatic line flushing, with the
specified file name.
This convenience constructor creates the necessary
intermediate ,
which will encode characters using the
instance of the Java virtual machine.
Parameters:fileName - The name of the file to use as the destination of this writer.
If the file exists then it will be tr
otherwise, a new file will be created.
The output will be
written to the file and is buffered.
- If the given string does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
- If a security manager is present and
denies write
access to the fileSince:
PrintWriter
public&PrintWriter(&fileName,
Creates a new PrintWriter, without automatic line flushing, with the
specified file name and charset.
This convenience constructor creates
the necessary intermediate , which will encode characters using the provided
Parameters:fileName - The name of the file to use as the destination of this writer.
If the file exists then it will be tr
otherwise, a new file will be created.
The output will be
written to the file and is buffered.csn - The name of a supported
- If the given string does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
- If a security manager is present and
denies write
access to the file
- If the named charset is not supportedSince:
PrintWriter
public&PrintWriter(&file)
Creates a new PrintWriter, without automatic line flushing, with the
specified file.
This convenience constructor creates the necessary
intermediate ,
which will encode characters using the
instance of the Java virtual machine.
Parameters:file - The file to use as the destination of this writer.
If the file
exists then it will be tr otherwise, a new
file will be created.
The output will be written to the file
and is buffered.
- If the given file object does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
- If a security manager is present and
denies write access to the fileSince:
PrintWriter
public&PrintWriter(&file,
Creates a new PrintWriter, without automatic line flushing, with the
specified file and charset.
This convenience constructor creates the
necessary intermediate , which will encode characters using the provided
Parameters:file - The file to use as the destination of this writer.
If the file
exists then it will be tr otherwise, a new
file will be created.
The output will be written to the file
and is buffered.csn - The name of a supported
- If the given file object does not denote an existing, writable
regular file and a new regular file of that name cannot be
created, or if some other error occurs while opening or
creating the file
- If a security manager is present and
denies write access to the file
- If the named charset is not supportedSince:
Method Detail
public&void&flush()
Flushes the stream.
Specified by:
&in interface&
Specified by:
&in class&
public&void&close()
Closes the stream and releases any system resources associated
with it. Closing a previously closed stream has no effect.
Specified by:
&in interface&
Specified by:
&in interface&
Specified by:
&in class&
checkError
public&boolean&checkError()
Flushes the stream if it's not closed and checks its error state.
Returns:true if the print stream has encountered an error,
either on the underlying output stream or during a format
conversion.
protected&void&setError()
Indicates that an error has occurred.
This method will cause subsequent invocations of
to return true until
is invoked.
clearError
protected&void&clearError()
Clears the error state of this stream.
This method will cause subsequent invocations of
to return false until another write
operation fails and invokes .
public&void&write(int&c)
Writes a single character.
Overrides:
&in class&
Parameters:c - int specifying a character to be written.
public&void&write(char[]&buf,
Writes A Portion of an array of characters.
Specified by:
&in class&
Parameters:buf - Array of charactersoff - Offset from which to start writing characterslen - Number of characters to write
public&void&write(char[]&buf)
Writes an array of characters.
This method cannot be inherited from the
Writer class because it must suppress I/O exceptions.
Overrides:
&in class&
Parameters:buf - Array of characters to be written
public&void&write(&s,
Writes a portion of a string.
Overrides:
&in class&
Parameters:s - A Stringoff - Offset from which to start writing characterslen - Number of characters to write
public&void&write(&s)
Writes a string.
This method cannot be inherited from the Writer class
because it must suppress I/O exceptions.
Overrides:
&in class&
Parameters:s - String to be written
public&void&print(boolean&b)
Prints a boolean value.
The string produced by
is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
Parameters:b - The boolean to be printed
public&void&print(char&c)
Prints a character.
The character is translated into one or more bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
Parameters:c - The char to be printed
public&void&print(int&i)
Prints an integer.
The string produced by
is translated into bytes according
to the platform's default character encoding, and these bytes are
written in exactly the manner of the
Parameters:i - The int to be printedSee Also:
public&void&print(long&l)
Prints a long integer.
The string produced by
is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
Parameters:l - The long to be printedSee Also:
public&void&print(float&f)
Prints a floating-point number.
The string produced by
is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
Parameters:f - The float to be printedSee Also:
public&void&print(double&d)
Prints a double-precision floating-point number.
The string produced by
is translated into
bytes according to the platform's default character encoding, and these
bytes are written in exactly the manner of the
Parameters:d - The double to be printedSee Also:
public&void&print(char[]&s)
Prints an array of characters.
The characters are converted into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
Parameters:s - The array of chars to be printed
- If s is null
public&void&print(&s)
Prints a string.
If the argument is null then the string
"null" is printed.
Otherwise, the string's characters are
converted into bytes according to the platform's default character
encoding, and these bytes are written in exactly the manner of the
Parameters:s - The String to be printed
public&void&print(&obj)
Prints an object.
The string produced by the
method is translated into bytes
according to the platform's default character encoding, and these bytes
are written in exactly the manner of the
Parameters:obj - The Object to be printedSee Also:
public&void&println()
Terminates the current line by writing the line separator string.
line separator string is defined by the system property
line.separator, and is not necessarily a single newline
character ('\n').
public&void&println(boolean&x)
Prints a boolean value and then terminates the line.
This method behaves
as though it invokes
Parameters:x - the boolean value to be printed
public&void&println(char&x)
Prints a character and then terminates the line.
This method behaves as
though it invokes
and then .
Parameters:x - the char value to be printed
public&void&println(int&x)
Prints an integer and then terminates the line.
This method behaves as
though it invokes
and then .
Parameters:x - the int value to be printed
public&void&println(long&x)
Prints a long integer and then terminates the line.
This method behaves
as though it invokes
Parameters:x - the long value to be printed
public&void&println(float&x)
Prints a floating-point number and then terminates the line.
This method
behaves as though it invokes
Parameters:x - the float value to be printed
public&void&println(double&x)
Prints a double-precision floating-point number and then terminates the
This method behaves as though it invokes
and then .
Parameters:x - the double value to be printed
public&void&println(char[]&x)
Prints an array of characters and then terminates the line.
This method
behaves as though it invokes
Parameters:x - the array of char values to be printed
public&void&println(&x)
Prints a String and then terminates the line.
This method behaves as
though it invokes
Parameters:x - the String value to be printed
public&void&println(&x)
Prints an Object and then terminates the line.
This method calls
at first String.valueOf(x) to get the printed object's string value,
then behaves as
though it invokes
Parameters:x - The Object to be printed.
public&&printf(&format,
A convenience method to write a formatted string to this writer using
the specified format string and arguments.
If automatic flushing is
enabled, calls to this method will flush the output buffer.
An invocation of this method of the form out.printf(format,
args) behaves in exactly the same way as the invocation
out.format(format, args)
Parameters:format - A format string as described in Format string syntax.args - Arguments referenced by the format specifiers in the format
If there are more arguments than format specifiers, the
extra arguments are ignored.
The number of arguments is
variable and may be zero.
The maximum number of arguments is
limited by the maximum dimension of a Java array as defined by
The Java& Virtual Machine Specification.
The behaviour on a
null argument depends on the conversion.
Returns:This writer
IllegalFormatException - If a format string contains an illegal syntax, a format
specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other
illegal conditions.
For specification of all possible
formatting errors, see the Details section of the
formatter class specification.
- If the format is nullSince:
public&&printf(&l,
A convenience method to write a formatted string to this writer using
the specified format string and arguments.
If automatic flushing is
enabled, calls to this method will flush the output buffer.
An invocation of this method of the form out.printf(l, format,
args) behaves in exactly the same way as the invocation
out.format(l, format, args)
Parameters:l - The
to apply during
formatting.
If l is null then no localization
is applied.format - A format string as described in Format string syntax.args - Arguments referenced by the format specifiers in the format
If there are more arguments than format specifiers, the
extra arguments are ignored.
The number of arguments is
variable and may be zero.
The maximum number of arguments is
limited by the maximum dimension of a Java array as defined by
The Java& Virtual Machine Specification.
The behaviour on a
null argument depends on the conversion.
Returns:This writer
IllegalFormatException - If a format string contains an illegal syntax, a format
specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other
illegal conditions.
For specification of all possible
formatting errors, see the Details section of the
formatter class specification.
- If the format is nullSince:
public&&format(&format,
Writes a formatted string to this writer using the specified format
string and arguments.
If automatic flushing is enabled, calls to this
method will flush the output buffer.
The locale always used is the one returned by , regardless of any
previous invocations of other formatting methods on this object.
Parameters:format - A format string as described in Format string syntax.args - Arguments referenced by the format specifiers in the format
If there are more arguments than format specifiers, the
extra arguments are ignored.
The number of arguments is
variable and may be zero.
The maximum number of arguments is
limited by the maximum dimension of a Java array as defined by
The Java& Virtual Machine Specification.
The behaviour on a
null argument depends on the conversion.
Returns:This writer
IllegalFormatException - If a format string contains an illegal syntax, a format
specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other
illegal conditions.
For specification of all possible
formatting errors, see the Details section of the
Formatter class specification.
- If the format is nullSince:
public&&format(&l,
Writes a formatted string to this writer using the specified format
string and arguments.
If automatic flushing is enabled, calls to this
method will flush the output buffer.
Parameters:l - The
to apply during
formatting.
If l is null then no localization
is applied.format - A format string as described in Format string syntax.args - Arguments referenced by the format specifiers in the format
If there are more arguments than format specifiers, the
extra arguments are ignored.
The number of arguments is
variable and may be zero.
The maximum number of arguments is
limited by the maximum dimension of a Java array as defined by
The Java& Virtual Machine Specification.
The behaviour on a
null argument depends on the conversion.
Returns:This writer
IllegalFormatException - If a format string contains an illegal syntax, a format
specifier that is incompatible with the given arguments,
insufficient arguments given the format string, or other
illegal conditions.
For specification of all possible
formatting errors, see the Details section of the
formatter class specification.
- If the format is nullSince:
public&&append(&csq)
Appends the specified character sequence to this writer.
An invocation of this method of the form out.append(csq)
behaves in exactly the same way as the invocation
out.write(csq.toString())
Depending on the specification of toString for the
character sequence csq, the entire sequence may not be
appended. For instance, invoking the toString method of a
character buffer will return a subsequence whose content depends upon
the buffer's position and limit.
Specified by:
&in interface&
Overrides:
&in class&
Parameters:csq - The character sequence to append.
null, then the four characters "null" are
appended to this writer.
Returns:This writerSince:
public&&append(&csq,
int&start,
Appends a subsequence of the specified character sequence to this writer.
An invocation of this method of the form out.append(csq, start,
end) when csq is not null, behaves in
exactly the same way as the invocation
out.write(csq.subSequence(start, end).toString())
Specified by:
&in interface&
Overrides:
&in class&
Parameters:csq - The character sequence from which a subsequence will be
If csq is null, then characters
will be appended as if csq contained the four
characters "null".start - The index of the first character in the subsequenceend - The index of the character following the last character in the
subsequence
Returns:This writer
- If start or end are negative, start
is greater than end, or end is greater than
csq.length()Since:
public&&append(char&c)
Appends the specified character to this writer.
An invocation of this method of the form out.append(c)
behaves in exactly the same way as the invocation
out.write(c)
Specified by:
&in interface&
Overrides:
&in class&
Parameters:c - The 16-bit character to append
Returns:This writerSince:
For further API reference and developer documentation, see . That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
© , Oracle and/or its affiliates.
All rights reserved.
Scripting on this page tracks web page traffic, but does not change the content in any way.}

我要回帖

更多关于 touch input是什么 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信