A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 那个Mr_Z 中级黑马   /  2014-4-21 11:09  /  1131 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

我一用NSLog输出汉字,就会报这个错误,请问我这个是什么原因,有的时候还会报那个 Codepoint out of range of the constant string,这是为什么,我用的Codeblock,请问我该怎么修改设置?
  还有:我一个代码的结果为0,请大家帮我看看我哪里出错了,谢谢
#import <Foundation\Foundation.h>
#import <math.h>
@interface Point2D : NSObject
{
    int _x;
    int _y;
}
- (void)setX:(int)x;
- (void)setY:(int)y;
- (int)x;
- (int)y;
- (void)setX:(int)x andY:(int)y;
- (int)distanceWithOther:(Point2D *)other;
@end

@implementation Point2D
- (void)setX:(int)x
{
        _x = x;
}
- (void)setY:(int)y
{
        _y =y;
}
-(int)x
{

    return _x;
}
-(int)y
{
    return _y;
}
- (void)setX:(int)x andY:(int)y
{
        [self x];
        [self y];
}
- (int)distanceWithOther:(Point2D *)other
{
             int a = [self x] - [other x];
             int b = [self y] - [other y];
             int c =  pow( a,2);
             int d =  pow( b,2);
            
             return sqrt(c+d);

}
@end

int main()
{
    Point2D *p1 = [Point2D new];
    [p1 setX:13 andY:25];
    Point2D *p2 = [Point2D new];
    [p2 setX:10 andY:21];
    int a = [p1 distanceWithOther:p2];
    NSLog(@"%d",a);
    return 0;
}

评分

参与人数 1黑马币 +2 收起 理由
jing迪 + 2

查看全部评分

3 个回复

倒序浏览
额,怎么变成表情了!!!!汗死....表情处代表冒号加半个括号,我晕。
回复 使用道具 举报
那个Mr_Z 发表于 2014-4-21 11:11
额,怎么变成表情了!!!!汗死....表情处代表冒号加半个括号,我晕。

你把代码发在程序里就不会出现这种现象了。
回复 使用道具 举报

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马