'Programming > JAVA,JSP' 카테고리의 다른 글
mysql table datetime tip (0) | 2014.10.20 |
---|---|
JSP, MYSQL, ECLIPSE 연동하기 (0) | 2014.10.12 |
JScrollPane , ScrollPane 차이점 (0) | 2014.07.12 |
Java ScrollPane 활용 (0) | 2014.07.12 |
java (0) | 2014.07.12 |
mysql table datetime tip (0) | 2014.10.20 |
---|---|
JSP, MYSQL, ECLIPSE 연동하기 (0) | 2014.10.12 |
JScrollPane , ScrollPane 차이점 (0) | 2014.07.12 |
Java ScrollPane 활용 (0) | 2014.07.12 |
java (0) | 2014.07.12 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
class RecvThread extends Thread {
Socket s;
public RecvThread(Socket s) {
this.s = s;
}
@Override
public void run() {
// 받는 부분
BufferedReader is;
try {
is = new BufferedReader(new InputStreamReader(s.getInputStream()));
String recvMsg;
while ((recvMsg = is.readLine()) != null) {
System.out.println(recvMsg);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class SendThread extends Thread {
Socket s;
public SendThread(Socket s) {
this.s = s;
}
@Override
public void run() {
PrintWriter os;
try {
os = new PrintWriter(s.getOutputStream(), true);
// 보내는 부분
Scanner sc = new Scanner(System.in);
while (true) {
String msg = sc.next();
os.println(msg);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public class ClientTest {
public static void main(String[] args) {
try {
Socket s = new Socket("115.20.247.142", 4000);
SendThread st = new SendThread(s);
RecvThread rt = new RecvThread(s);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Java ScrollPane 활용 (0) | 2014.07.12 |
---|---|
java (0) | 2014.07.12 |
Java 선택 정렬 알고리즘 구현 (0) | 2014.06.14 |
String to int, int to String (0) | 2014.06.07 |
이클립스 라인넘버 표시 (1) | 2014.03.07 |
#include <stdio.h>
int isLeapYear(int year);
int totalDaysYearMonth(int year, int month);
// year : 년도month : 월을입력하면그년도그월의총일수가
// 반환된다.
int totalDaysYear(int year);
int firstDayOfYear(int year);
int DayOfWeekYearMonth(int year, int month);
// year : 년도month : 월을입력하면그년도그월의요일이
// 반환된다.
int main( )
{
int year;
int month;
int i;
int totalDay = 0;
printf("연,월을입력하시오:");
scanf("%d,%d", &year, &month);
printf("%d\n", DayOfWeekYearMonth(year, month));
return 0;
}
int DayOfWeekYearMonth(int year, int month)
{
int i;
int totalDay = 0;
totalDay = firstDayOfYear(year);
for( i = 1 ; i < month ; i++)
{
totalDay += totalDaysYearMonth(year, i);
}
return totalDay % 7;
}
int firstDayOfYear(int year)
{
int i;
int totalDay = 0;
for ( i = 1980 ; i < year ; i++ )
{
totalDay += totalDaysYear(i);
}
return totalDay % 7;
}
int totalDaysYear(int year)
{
if( isLeapYear(year) )
{
return 366;
}
else
{
return 365;
}
}
int totalDaysYearMonth(int year, int month)
{
if( month == 1 || month == 3 ||
month == 5 || month == 7 ||
month == 8 || month == 10 ||
month == 12 )
{
return 31;
}
else
{
if( month == 2 )
{
if( isLeapYear(year) )
{
return 29;
}
else
{
return 28;
}
}
else
{
return 30;
}
}
}
int isLeapYear(int year)
{
if( ( (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) )
{
return 1;
}
else
{
return 0;
}
}
studentInfo 실습 (1) | 2014.04.19 |
---|---|
C 배열 연습문제 (0) | 2014.04.13 |
C 배열 실습 10명 성적처리 (0) | 2014.04.05 |
별 찍기 예제 #3 (0) | 2014.03.29 |
별 찍기 예제 #2 (0) | 2014.03.29 |