
机试题
文章平均质量分 55
xdtongyuan
这个作者很懒,什么都没留下…
展开
-
整型转化为字符串
// 整型转化为字符串(自己).cpp : Defines the entry point for the console application.//#include "stdafx.h"void itoa(int a , char s[]);int main(int argc, char* argv[]){ int n; char s[100]; printf("输原创 2013-06-08 14:44:35 · 641 阅读 · 0 评论 -
去掉最大和最小,再求平均值
去掉一个数组里的最大值与最小值,求数组元素的平均值。函数接口为:float avescore(float score[] ,int n)解析:此题比较简单,循环一遍,记下数组的最大值与最小值以及总和,然后在求的总和里面减掉最大值与最小值,再求平均数即可,时间复杂度为O(n)// test1.cpp : Defines the entry point for the console applic原创 2013-06-08 15:53:50 · 12520 阅读 · 0 评论 -
练习题
char *str_1 = "12345";char str_2[ ] = "12345";char str_3[5] = { '1' };char str_4[5] = { '1', '2', '3', '4', '5' };表达式 值sizeof( str_1 )转载 2013-06-08 22:16:10 · 599 阅读 · 0 评论 -
判断字符串是否为回文
// 判断字符串是否为回文.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include int invert(char str[]){ int i=0; int j; int len=strlen(str); j=len-1; while ((i<j)&&原创 2013-06-18 22:55:04 · 700 阅读 · 0 评论 -
实现矩阵对角线输出
实现程序,输入一个N*N的矩阵,对角线输出每个元素,大概意思如下: 比如输入4*4的矩阵:{{0, 1, 2, 3},{4, 5, 6, 7},{8, 9,10,11},{12,13,14,15}}输出为 :0,1,4,2,5,8,3,6,9,12 …[cpp] view plaincopyvoid main(转载 2013-06-24 22:16:33 · 1690 阅读 · 0 评论 -
华为的一道题
看了别人的解法没有看懂,自己写的int A[nSize],其中隐藏着若干0,其余非0整数,写一个函数int Func(int* A, int nSize),使A把0移至后面,非0整数移至 数组前面并保持有序,返回值为原数据中第一个元素为0的下标。(尽可能不使用辅助空间且考虑效率及异常问题,注释规范且给出设计思路)// 0再前非零在后.cpp : Defines the entry原创 2013-06-27 14:31:09 · 960 阅读 · 0 评论