作者johnlinvc (阿翔)
看板C_and_CPP
标题Re: [问题] c语言程式求助
时间Wed Oct 14 15:42:58 2009
快速上升中 前十名目指 obj-c
因应观众要求,换个更obj-C的板本
#import <Foundation/Foundation.h>
@interface person:NSObject
{
double weight;
}
@property double weight;
-(double)pound;
@end
@implementation person
@synthesize weight;
-(double)pound{
return weight/0.454;
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Enter your weight(kg)");
double weight=0;
scanf("%d",&weight);
person * I = [[person alloc] init];
[I setWeight:weight];
NSLog(@"Your weight is %d pound",[I pound]);
[pool drain];
return 0;
}
--
◤ ◥ ◢ ◣
杰米,炸掉它吧。 ⊙▁⊙─ ─⊙▂⊙ 碰到问题,用C4就对了!
╰ ∕皿﹨ ◥皿◤ ╯
◥█◤◢ ◥ ︶◤
Adam Savage ◤ ︶ ◥◤ ﹨▼∕◥ Jamie Hyneman
MYTHBUSTERS ◥ ◤\◥ by dajidali
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.244.225
1F:→ jlovet:明明跟C没差别 10/14 16:29
2F:推 Ebergies:名字都叫 Objective-C 了 lol 10/14 16:38
3F:推 StubbornLin:天阿 我刚看了一下Objective-C的语法... 10/14 16:43
4F:→ StubbornLin:怎麽可以这麽恶心... 看到我快吐了 orz 10/14 16:44
5F:→ StubbornLin:我曾经写过一点GNU的CObject 已经很恶心了= .= 10/14 16:44
6F:→ StubbornLin:ObjC...更是... = =" 10/14 16:44
※ 编辑: johnlinvc 来自: 140.112.244.225 (10/14 17:34)