//
// main.m
// 10.27*****
//
// Created by on 15/10/27.
// Copyright (c) 2015年 . All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Student.h"
#import "Teacher.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
Teacher *jieyang=[[Teacher alloc]init];
jieyang.age=25;
jieyang.grade=@"高级";
NSMutableArray *name=[NSMutableArray arrayWithObjects:@"赵三",@"钱三",@"孙三",@"李三",@"周三",@"吴三",@"郑三",@"王三",@"张宇",@"李荣生", nil];
NSMutableArray *score=[NSMutableArray arrayWithObjects:@"85",@"69",@"97",@"84",@"57",@"88",@"99",@"87",@"100",@"100",nil];
// NSDictionary *st=@{name[0]:score[0],name[1]:score[1],name[2]:score[2],name[3]:score[3],name[4]:score[4],name[5]:score[5],name[6]:score[6],name[7]:score[7],name[8]:score[8],name[9]:score[9]};
int a=(int)score.count;
for (int j=0; j<a+7; j++) { //为什么a+7?
for (int i=0; i<a-i+7; i++) { //为什么a-i+7?
//如果改为a-1的话就排不完了
float a=[score[i] floatValue];
float b=[score[i+1] floatValue];
if (a<b) {
[score exchangeObjectAtIndex:i withObjectAtIndex:(i+1)];
[name exchangeObjectAtIndex:i withObjectAtIndex:(i+1)];
}
}
}
for (int i=0; i<score.count; i++) {
NSArray *arr1=name[i];
NSArray *arr=score[i];
NSLog(@"%@的成绩是:%@",arr1,arr);
}
float total = 0.0;
for (NSString *s in score) {
float a=[s floatValue];
total=a+total;
}
float avy=total/10;
NSLog(@"xx老师班学生的平均成绩为%f",avy);
NSString *grad;
if (avy>=90) {
grad=@"高级讲师";
NSLog(@"xx老师现在等级为%@",grad);
}else if (avy>=80){
grad=@"中级讲师";
NSLog(@"xx老师现在等级为%@",grad);
}else if (avy>=75){
grad=@"低级讲师";
NSLog(@"xx老师现在等级为%@",grad);
}else if (avy<75){
grad=@"实习讲师";
NSLog(@"xx老师现在等级为%@",grad);
}
}
return 0;
}
//
// Teacher.h
// 10.27*****
//
// Created by on 15/10/27.
// Copyright (c) 2015年 . All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Student.h"
@interface Teacher : NSObject
@property (nonatomic,assign) int age;
@property (nonatomic,strong) NSString *grade;
@end
//
// Teacher.m
// 10.27*****
//
// Created by on 15/10/27.
// Copyright (c) 2015年 . All rights reserved.
//
#import "Teacher.h"
@implementation Teacher
@end
//
// Student.h
// 10.27*****
//
// Created by on 15/10/27.
// Copyright (c) 2015年 . All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Student : NSObject
@property (nonatomic,strong) NSString *name;
@property (nonatomic,assign) float score;
@end
//
// Student.m
// 10.27*****
//
// Created by on 15/10/27.
// Copyright (c) 2015年 . All rights reserved.
//
#import "Student.h"
@implementation Student
@end