100): print(" Out of range!!!") n = input(" Enter the number of pe.Join the community and post comments on the topics"> #input number n = input("Enter the number for people:") while (n <


#input number n = input("Enter the number for people:") while (n < - TopicsExpress



          

#input number n = input("Enter the number for people:") while (n < 1 or n > 100): print(" Out of range!!!") n = input(" Enter the number of peple: ") names = [] dates = [] months = [] years = [] for i in range(0,n): line = raw_input("person #" + str(i+1)+":") words = line.split() # name of person -> names[] /list names.insert(i,words[0]) #get birth date -> dates[] dates.insert(i,words[1]) #birth month -> months[] months.insert(i,words[2]) #birth year -> years[] years.insert(i,words[3]) #Out loop for i in range(n-1): #inner loop for j in range(n-1): #compare two birthday,swap if necssary if years[j] > years[j+1]: temp_years = years[j] years[j] = years[j+1] years[j+1] = temp_years temp_months = months[j] months[j] = months[j+1] months[j+1] = temp_months temp_dates = dates[j] dates[j] = dates[j+1] dates[j+1] = temp_dates temp_names = names[j] names[j] = names[j+1] names[j+1] = temp_names elif years[j] == years[j+1]: temp_years = years[j] years[j] = years[j+1] yers[j+1] = temp_years temp_months = months[j] months[j] = months[j+1] months[j+1] = temp_months temp_dates = dates[j] dates[j] = dates[j+1] dates[j+1] = temp_dates temp_names = names[j] names[j] = name[j+1] name[j+1] = temp_names elif months[j] == months[j+1]: if dates[j] > dates[j+1]: temp_years = years[j] years[j] = years[j+1] yers[j+1] = temp_years temp_months = months[j] months[j] = months[j+1] months[j+1] = temp_months temp_dates = dates[j] dates[j] = dates[j+1] dates[j+1] = temp_dates temp_names = names[j] names[j] = name[j+1] name[j+1] = temp_names #3. Show result #3.1 print youngest print(names[ n - 1]) #3.2 print oldest print(names[0]) ถูกไหมเนี่ยยๆ เช็คให้หน่อยๆ
Posted on: Wed, 10 Jul 2013 09:57:49 +0000

Trending Topics



Recently Viewed Topics




© 2015