cvte笔试题

cvte技术支持笔试题
20个不定选择,一共90分钟
1 在一个字符串中找到第一个只出现一次的字符。
如输入”abaccdeff”,输出’b’
如果都出现多次,则输出输入次数最多的那个


char FirstNotRepeatChar(string s) {
    int size = s.length();
    if (size == 0)
        return '\0';
    const int M = 255; // 表大小,char :1 Byte,0~255
    int[] count=new int[M];
    for (int i = 0; i < M; i++)
        count[i] = 0;
    for (int j = 0; j < size; j++)
        count[s[j]-'\0']++;
    char result;
    for (int i = 0; i < size; i++) {
        if (count[s[i]-'\0'] == 1) {
            result = s[i];
            break;
        }
    }
    delete []count;
    return result;
}
int main() {
    string s = "testonline";
    cout << FirstNotRepeatChar(s) << endl;
}

2以单词为单位的逆序排序
输入:hello world
输出: world hello

#include <stdio.h>
#include <string.h>
int main()
{
char s[3000],c[1000][20]={0};//c[j]来储存单词,k是单词中的字母
int i,j=0,k=0;
gets(s);
for(i=0; i<strlen(s); i++)
{
if(s[i]==' ')
{
j++; //遇空格换下一个单词,k归零
k=0;
continue;
}
c[j][k]=s[i];
k++;
}
for(i=j; i>=0; i--)//逆序输出
printf("%s ",c[i]);
} 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值