목록전체 글 (444)
printf("ho_tari\n");

for looper in [1, 2, 3, 4, 5]: print("hello") for looper in [1, 2, 3, 4, 5]: print(looper) for looper in range(10): print("hello") for i in 'abcdefg': print(i) for i in ['americano', 'latte', 'frappuccino']: print(i) for i in range(1, 10, 2): # 1부터 9까지 2씩 증가시키면서 반복문 수행 print(i) for i in range(10, 1, -1): # 10부터 2까지 1씩 감소시키면서 반복문 수행 print(i) i = 1 # i 변수에 1 할당 while i < 10: # i가 10미만인지 판단 print(i..

(점수를 입력하면 어떤 학점으로 계산되는가) score = int(input("Enter your score: ")) if score >= 90: grade = 'A' elif score >= 80: grade = 'B' elif score >= 70: grade = 'C' elif score >= 60: grade = 'D' else: grade = 'F' print(grade) (어떤 종류의 학생인지 맞히기) print("당신이 태어난 연도를 입력하세요.") birth_year = input() age = 2023 - int(birth_year) + 1 print(age) if age = 20: print("대학생") elif age = 17: print("고등학생") eli..

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