1.
import java.util.Scanner;
public class T {
public static void main(String[] args) {
System.out.println("5+5="+5+5);
}
}
2.
(1)
import java.util.Scanner;
public class G{
public static void main(String[] args) {
int a=3,b;
b=a++;
sop("a="+a+",b="+b);
int a=3,b;
b=++a;
sop("a="+a+",b="+b);
}
}
(2).
public class H
{
public static void main (String[] args){
int a=3,b;
b=++a;
System.out.println("a="+a+",b="+b);
}
}
3.
import java.util.Scanner;
public class I {
public static void main(String[] args) {
short s=3;
s=s+4;
sop("s="+s);
short s=3;
s+=4;
sop("s="+s);
}
}
4.
import java.util.Scanner;
public class J{
public static void main(String[] args) {
sop(6&3);
sop(6|3);
sop(6^3);
sop(3<<2);
sop(3>>1);
}
}
5.
import java.util.Scanner;
public class K {
public static void main(String[] args) {
int x=0,y;
y=x>1?100:200;
sop("y="+y);
}
}
(1).输出两个整数中较大的整数
public class M
{
public static void main (String[] args){
int a=1,b=0,max;
max=a>b?a:b;
System.out.println("max="+a);
}
}
(2) 输出三个整数中最大的整数
public class M2
{
public static void main (String[] args){
int a=1,b=0,c=3,max;
max=a>b?a:b;
max=c>max?c:max;
System.out.println("max="+c);
}
}
6.
import java.util.Scanner;
public class N {
public static void main(String[] args) {
int weekDay=3;
if(weekDay==1){
sop("今天是星期一");
}
else if(weekDay==2){
sop("今天是星期二");
}
else if(weekDay==3){
sop("今天是星期三");
}
else{
sop("没有这一天");
}
int month=8;
}
}
(2)使用关联的if语句
public class O
{
public static void main (String[] args){
int weekDay=3;
if(weekDay==1){
System.out.println("今天是星期一");
}else if(weekDay==2){
System.out.println("今天是星期二");
}else if(weekDay==3){
System.out.println("今天是星期三");
}else if(weekDay==4){
System.out.println("今天是星期四");
}else if(weekDay==5){
System.out.println("今天是星期五");
}else if(weekDay==6){
System.out.println("今天是星期六");
}else if(weekDay==7){
System.out.println("今天是星期七");
}
else{
System.out.println("没有这一天");
}
}
}
练习.
public class P
{
public static void main (String[] args){
int month=3;
if(month==1){
System.out.println("这个月是冬天");
}
if(month==2){
System.out.println("这个月是冬天");
}
if(month==3){
System.out.println("这个月是春天");
}
if(month==4){
System.out.println("这个月是春天");
}
if(month==5){
System.out.println("这个月是春天");
}
if(month==6){
System.out.println("这个月是夏天");
}
if(month==7){
System.out.println("这个月是夏天");
}
if(month==8){
System.out.println("这个月是夏天");
}
if(month==9){
System.out.println("这个月是秋天");
}
if(month==10){
System.out.println("这个月是秋天");
}
if(month==11){
System.out.println("这个月是秋天");
}
if(month==12){
System.out.println("这个月是冬天");
}
System.out.println(month);
}
}
7.
import java.util.Scanner;
public class CH {
public static void main(String[] args) {
int a=84,b=3;
char option='%';
switch (option)
{
case '+':
System.out.println("a+b="+(a+b));
break;
case '-':
System.out.println("a-b="+(a-b));
break;
case '*':
System.out.println("a*b="+(a*b));
break;
case '/':
System.out.println("a/b="+(a/b));
break;
case '%':
System.out.println("a%b="+(a%b));
break;
default:
System.out.println("a%b="+(a%b));
break;
}
}
}
8.
import java.util.Scanner;
public class CH {
public static void main(String[] args) {
int x=1;
do{
sop("x="+x);
x++;
}
while(x<1);
}
}
import java.util.Scanner;
public class CH {
public static void main(String[] args) {
int y=1;
while(y<1){
sop("y="+y);
y++;
}
}
}
9.
import java.util.Scanner;
public class CH {
public static void main(String[] args) {
for(int x=1;x<3;x++)
{
sop("x="+x);
}
}
}
9.
import java.util.Scanner;
public class CH {
public static void main(String[] args) {
for(sop("a");sop("b");sop("c")
{
sop("d");
}
}
}
HDU 2222 Keywords Search (AC自动机)
HDU 2457 DNA repair (AC自动机+DP)
CoFun 1612 单词分组(容斥)
邓_mysql_面试
Html5+js测试题(开发版)
Html5+js测试题【完整版】
HTML面试
支付宝+微信=合成二维码
邓_laravel框架——news
- 最新文章
-
【过时】项目转Maven后出现的问题记录
20170808看视频整理优化方案
【需要重新整理】【mongoDB】mongoDB初见笔记
【工具】java发送GET、POST请求
SPOJ LGLOVE 7488 LCM GCD Love (区间更新,预处理出LCM(1,2,...,n))
codeforces 295E Yaroslav and Points (离线操作+离散化+区间合并)
SPOJ CNTPRIME 13015 Counting Primes (水题,区间更新,求区间的素数个数)
SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)
SPOJ 7259 Light Switching (水题,区间01取反)
CF 295A Greg and Array (两次建树,区间更新,单点查询)
- 热门文章
-
SPOJ MULTQ3 7299 Multiples of 3 (区间更新)
HDU 1540 / POJ 2892 Tunnel Warfare (单点更新,区间合并,求包含某点的最大连续个数)
HDU 3397 Sequence operation (区间合并,操作比较多)
POJ 3468 A Simple Problem with Integers(线段树区间更新,模板题,求区间和)
HDU 3516 Tree Construction (四边形不等式)
BZOJ 2626 JZPFAR(KD-tree)
伪造队形(FFT)
POJ 2653 Pick-up sticks(线段相交)
POJ 2778 DNA Sequence (AC自动机,矩阵乘法)
HDU 3065 病毒侵袭持续中 (AC自动机)