函数
来源:互联网 发布:bms算法 编辑:程序博客网 时间:2024/05/17 02:26
//
// myFunction.m
// day5
//
// Created by dllo on 15/11/17.
// Copyright © 2015年 dllo. All rights reserved.
//
#import "myFunction.h"
//1.用函数实现 :随机产生20个[10 , 100]的正整数,输出这些数以及他们中的最大数,
//void max(int arr[]){
// for (int i = 0; i<20; i++) {
// arr[i]=arc4random()%(100-10-1)+10;
// printf("%d ",arr[i]);
// }
// printf("\n");
//
//
// int max =0;
// for (int i = 0 ; i<20; i++) {
// if (max<arr[i]) {
// max=arr[i];
// }
// }
// printf("%d\n",max);
//}
//
//2.2. 用函数实现 :编程将所有“水仙花数”打印出来,并打印其总个数。 “水仙花数”是一个各个位立方之和等于该整数的三位数
//void flower(){
// int count =0;
// for (int i = 100; i<1000; i++) {
// int a= i/100,b=i/10%10,c=i%10;
//
// if (a*a*a+b*b*b+c*c*c==i) {
// printf("%d ",i);
// count ++;
// }
// }
// printf("\n");
// printf("%d\n",count );
//}
//3. 用函数实现 :输入一个整数,判断奇偶,并返回判断结果(BOOL)
//int oddEven (){
// int n=0;
// scanf("%d",&n);
// BOOL isTrue=n%2==0;
// return isTrue ;
//}
//
//4.4. 用函数实现 :输入一个数,判断符号。如果大于0,输出“正数”;如果小于0,输出“负数”;如果等于0,输出“0”
//void positiveMinus(){
// int number=0;
// scanf("%d",&number);
// if (number >0) {
// printf("正数\n");
// }else if (number<0){
// printf("负数\n");
// }else{
// printf("0\n");
// }
//}
//5. 用函数实现 : 已知abc+cba = 1333,其中a,b,c均为一位数,编程求出满足条件的a,b,c所有组合
void number(){
for (int i =100; i<1000; i++) {
if (i/100+i/10%10*10+i%10*100+i==1333) {
printf("%d ",i);
}
}
printf("\n");
}
/////////////////////////////////////////
//
// myFunction.h
// day5
//
// Created by dllo on 15/11/17.
// Copyright © 2015年 dllo. All rights reserved.
//
#import <Foundation/Foundation.h>
//1.
//void max(int arr[]);
//2
//void flower();
//3
int oddEven ();
//4
//void positiveMinus();
//5
void number();
///////////////////////////////////
//
// main.m
// day5
//
// Created by dllo on 15/11/17.
// Copyright © 2015年 dllo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "myFunction.h"
int main(int argc,const char * argv[]) {
//1
// int arr[20]={0};
// max(arr);
//2
// flower();
//3
// if(oddEven()==1){
// printf("偶数\n");
// }else{
// printf("奇数\n");
// }
//4
// positiveMinus();
//
//5
number();
return 0;
}
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- 函数
- Linux spi驱动分析(二)----SPI核心(bus、device_driver和device)
- js获取select标签选中的值
- Android SwipeRefreshLayout 官方下拉刷新控件介绍
- iOS中 MediaPlayer framework实现视频播放 韩俊强的博客
- 第一章c语言概述
- 函数
- 1,5-萘啶254甲硫芬
- 使用百度地图API,定位并显示自己的位置
- CodeForces 260B Ancient Prophesy 模拟
- php面试
- 哈夫曼树的创建以及编码
- Leetcode159: Fraction to Recurring Decimal
- CSS布局 ——从display,position, float属性谈起
- 参加Autodesk 2015 开发者大会:物联网有意思的试验