标签:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// 定义日常生活中的例子
int age = 18;
float weight = 56.5;
//控制台打印
/*
int i,a;
for (i=1; i<=6; i++) {
for (a = 1;a <= i;a++){
printf("*");
}
printf("\n");
}
*/
printf("*\n");
printf("* *\n");
printf("* * *\n");
printf("* * * *\n");
printf("* * * * *\n");
printf("* * * * * *\n");
//输入美元返回人民币
float dollar,rmb;
printf("请输入美元的数量\n");
scanf("%f",&dollar);
printf("rmb=%f\n",rmb=dollar*6.3417);
//输入两个整数,并求其和、差、积、余数。
int x ,y,sum;
printf("请输入两个整数:\n");
scanf("%d %d",&x,&y);
printf("sum=%d\n",sum =x+y);
printf("sum=%d\n",sum =x-y);
printf("sum=%d\n",sum =x*y);
printf("sum=%d\n",sum =x%y);
//声明变量包括:
//类型修饰符 变量的名字 = 初始值;
/*
变量命名规则:
只能由数字、字母、下划线组成,并且数字不能开头
不能和系统关键字同名
不能使用重复的变量名
见名知意
驼峰式命名 ageZhangMang
*/
int m = 456;
char c = ‘/‘;
short n = 1234;
float f = 3.2345;//(保留两位有效数字)
long l = 12345678;
double d= 12.345678911;//(保留四位有效数字)
printf(" %d\n %c\n %hd\n %.1f\n %ld\n %.2f\n",m,c,n,f,l,d);
//求3和5的和、差、积、余数
int a = 3,b = 5;
printf("%d\n",a+=b);
a=3;
printf("%d\n",a-=b);
a=3;
printf("%d\n",a*=b);
a=3;
printf("%d\n",a%=b);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/lzp-1713396133/p/4876001.html