九度题目练习之求职面试题集
来源:互联网 发布:微商天下软件 编辑:程序博客网 时间:2024/06/06 13:56
题目1039:Zero-complexity Transposition
题目描述:
You are given a sequence of integer numbers. Zero-complexity transposition of the sequence is the reverse of this sequence. Your task is to write a program that prints zero-complexity transposition of the given sequence.
输入:
For each case, the first line of the input file contains one integer n-length of the sequence (0 < n ≤ 10 000). The second line contains n integers numbers-a1, a2, …, an (-1 000 000 000 000 000 ≤ ai ≤ 1 000 000 000 000 000).
输出:
For each case, on the first line of the output file print the sequence in the reverse order.
样例输入:
5-3 4 6 -8 9
样例输出:
9 -8 6 4 -3
代码:
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int main(){ int m, n, i; long long num[10000]; while(scanf("%d",&m)!=EOF){ getchar(); for(i=0;i<m;i++){ scanf("%lld",&num[i]); } for(i=m-1; i>=0;i--){ printf("%lld%c",num[i],i==0?'\n':' '); } } return 0;}
关键点:后面逆序输入的数字的范围需要用long long类型,并且scanf中需要使用%lld
题目1510:替换空格
题目描述:
请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
输入:
每个输入文件仅包含一组测试样例。对于每组测试案例,输入一行代表要处理的字符串。
输出:
对应每个测试案例,出经过处理后的字符串。
样例输入:
We Are Happy
样例输出:
We%20Are%20Happy
代码:
int main(){ char str[10000]; char tmp[10000]; while(gets(str)!=NULL){ int len = strlen(str); int j=0; for(int i=0;i<len;i++){ if(str[i]==' '){ tmp[j++]='%'; tmp[j++]='2'; tmp[j++]='0'; } else tmp[j++]=str[i]; } tmp[j]=0; printf("%s\n",tmp); } return 0;}
题目1511:从尾到头打印链表
题目描述:
输入一个链表,从尾到头打印链表每个节点的值。
输入:
每个输入文件仅包含一组测试样例。每一组测试案例包含多行,每行一个大于0的整数,代表一个链表的节点。第一行是链表第一个节点的值,依次类推。当输入到-1时代表链表输入完毕。-1本身不属于链表。
输出:
对应每个测试案例,以从尾到头的顺序输出链表每个节点的值,每个值占一行。
样例输入:
12345-1
样例输出:
54321
代码:
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int main(){ int m, n, i=0; int num[10000]; while(scanf("%d",&num[i++])!=EOF){ do{ scanf("%d",&num[i++]); }while(num[i-1]!=-1); for(int j=i-2;j>=0;j--){ printf("%d\n",num[j]); } i=0; } return 0;}
后面两题都还没有提交通过,明天再来修改一下。
阅读全文
0 0
- 九度题目练习之求职面试题集
- 九度Online Judge求职面试题集及解题思路
- 九度Online Judge求职面试题集及解题思路
- 九度Online Judge求职面试题集及解题思路
- 求职之面试题总结
- 面试题之九
- iOS求职之C语言面试题
- iOS求职之OC面试题
- iOS求职之iOS面试题
- IOS求职之OC面试题
- iOS求职之iOS面试题
- iOS求职之OC面试题
- iOS求职之C语言面试题
- IOS求职之OC面试题
- iOS求职之OC面试题
- iOS求职之C语言面试题
- iOS求职之OC面试题
- iOS求职之OC面试题
- INNO SETUP 注册OCX
- Maven Settings
- 淘淘商城系列——使用SolrJ查询索引库
- B-1015
- 什么是单元测试
- 九度题目练习之求职面试题集
- [ubuntu] 安装chrome浏览器
- Android控件5
- js获取select标签选中的值
- Hololens——开发入门
- Android 蓝牙开发(十)A2DP源码分析
- Android常用控件-01
- CF Round #418( Div.2) An impassioned circulation of affection
- 新浪实时股票数据接口http://hq.sinajs.cn/list=code