Array Partition I
来源:互联网 发布:java socket 发送超时 编辑:程序博客网 时间:2024/06/05 15:32
#include <stdio.h>#include <string.h>void swap(int *a, int *b){int temp;temp = *a;*a = *b;*b = temp;}int arrayPairSum(int* nums, int numsSize) {int i, j, temp;for (i = 0; i < numsSize; i++){for (j = numsSize - 1; j >i; j--){if (nums[j] < nums[j - 1]){swap(&nums[j], &nums[j-1]);}}}temp = 0;for (i = 0; i < numsSize; i+=2){temp += nums[i];}return temp;}void main() {int input[8] = {1,4,3,2 };printf("%d", arrayPairSum(input, 2));system("pause");}
阅读全文
0 0
- Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- Array Partition I
- LeetCode Array Partition I
- 561. Array Partition I
- Array Partition I
- 561. Array Partition I
- 561. Array Partition I
- leetCode---Array Partition I
- 561. Array Partition I
- 10_ARM汇编自学笔记指令系统之乘法指令与乘加指令
- 登陆3次 不成功则无法继续
- LeetCode-1. Two Sum
- leetcode 132 Pattern
- 面向对象的几个问题
- Array Partition I
- Spring Cloud构建微服务架构:服务消费(Ribbon)【Dalston版】
- MAMP PRO的mySQL启动失败
- [leetcode]517. Super Washing Machines
- 1049. 数列的片段和(20)
- 冒泡事件、默认事件、事件委托、事件监听和事件捕获
- sqlserver、Mysql、Oracle三种数据库的优缺点总结
- ELF文件格式及其他
- Activity的启动模式(一)