목록전체 글 (316)
printf("ho_tari\n");
colors = ['red', 'blue', 'green'] print(colors[0]) print(colors[2]) print(len(colors)) cities = ['서울', '부산', '인천', '대구', '대전', '광주', '울산', '수원'] print(cities[0:6]) # 파이썬의 리스트에서 마지막 인덱스값은 출력되지 않는다 print(cities[0:5]) print(cities[5:]) cities = ['서울', '부산', '인천', '대구', '대전', '광주', '울산', '수원'] print(cities[-8:])# -8의 인덱스값부터 끝까지 print(cities[:]) # cities 변수의 처음부터 끝까지 print(cities[-50:50]) # 범위를 넘어갈 결..
print("Enter your name:") somebody = input() print("Hi", somebody, "How are you today?") temperature = float(input("온도를 입력하세요: ")) print(temperature) print("본 프로그램은 섭씨온도를 화씨온도로 변환하는 프로그램입니다.") print("변환하고 싶은 섭씨온도를 입력하세요.") celsius = input() fahrenheit = (float(celsius) * 1.8) + 32 print("섭씨온도:", celsius) print("화씨온도:", fahrenheit)
#include #include #include #include void* thread_main1(void *arg); void* thread_main2(void *arg); void* thread_main3(void *arg); static sem_t sem_one; static sem_t sem_two; static sem_t sem_three; int main(int argc, char *argv[]) { pthread_t t1_id, t2_id, t3_id; int thread_param=5; sem_init(&sem_one, 0, 0); sem_init(&sem_two, 0, 0); sem_init(&sem_three, 0, 1); pthread_create(&t1_id, NULL, thread..
#include #include #include void * read(void * arg); void * accu(void * arg); static sem_t sem_one; static sem_t sem_two; static int num; int main(int argc, char *argv[]) { pthread_t id_t1, id_t2; sem_init(&sem_one, 0, 0); sem_init(&sem_two, 0, 1); pthread_create(&id_t1, NULL, read, NULL); pthread_create(&id_t2, NULL, accu, NULL); pthread_join(id_t1, NULL); pthread_join(id_t2, NULL); sem_destroy(..
#include #include #define NUM_THREAD100 void * thread_inc(void * arg); void * thread_des(void * arg); long long num=0; pthread_mutex_t mutex; int main(int argc, char *argv[]) { pthread_t thread_id[NUM_THREAD]; int i; pthread_mutex_init(&mutex, NULL); printf("sizeof long long: %d \n", sizeof(long long)); for(i=0; i
#include #include #include #include void error_handling(char *message); int main(int argc, char *argv[]) { int sock; int snd_buf, rcv_buf, state; socklen_t len; sock=socket(PF_INET, SOCK_STREAM, 0); len=sizeof(snd_buf); state=getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void*)&snd_buf, &len); if(state) error_handling("getsockopt() error"); len=sizeof(rcv_buf); state=getsockopt(sock, SOL_SOCKET, SO_R..
#include #include #include #include #include void error_handling(char *message); int main(int argc, char *argv[]) { int i; struct hostent *host; if(argc!=2) { printf("Usage : %s \n", argv[0]); exit(1); } host=gethostbyname(argv[1]); if(!host) error_handling("gethost... error"); printf("Official name: %s \n", host->h_name); for(i=0; host->h_aliases[i]; i++) printf("Aliases %d: %s \n", i+1, host->..