2011年哈尔滨工业大学计算机研究生机试真题

题目连接:点击打开链接

解题思路:

暴力

完整代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int INF = 1000000000;
string s;
int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    while(cin >> s)
    {
        string temp = "";
        int len = s.length();
        for(int i = len - 1 ; i >= 0 ; i --)
            temp += s[i];
        cout << temp << endl;
    }
}

题目连接:点击打开链接

解题思路:

函数秒杀众生

完整代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int INF = 1000000000;
int a , b;
int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    while(cin >> a >> b)
    {
        cout << __gcd(a , b) << endl;
    }
}
 

题目连接:点击打开链接

解题思路:

暴力

完整代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int INF = 1000000000;
int a[10001];
int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    memset(a , 0 , sizeof(a));
    int k , cnt = 0;
    while(cin >> k)
    {
        cnt ++;
        if(cnt == 20)
        {
            cnt = 0;
            int maxx = -INF , pos;
            for(int i = 1 ; i <= 20 ; i ++)
            {
                if(a[i] > maxx)
                {
                    maxx = a[i];
                    pos = i;
                }
            }
            cout << pos << endl;
            memset(a , 0 , sizeof(a));
        }
        a[k]++;
    }
}
时间: 2024-08-27 22:08:47

2011年哈尔滨工业大学计算机研究生机试真题的相关文章

字符串去特定字符-2009年哈尔滨工业大学计算机研究生机试真题

题目描述: 输入字符串s和字符c,要求去掉s中所有的c字符,并输出结果. 输入: 测试数据有多组,每组输入字符串s和字符c. 输出: 对于每组输入,输出去除c字符后的结果. 样例输入: heallo    a 样例输出: hello 解题代码: 解法1:使用两个数组, 第二个数组存储去掉特定字符的字符串 #include <stdio.h> int main(){ char arr[200]; char arrNew[200]; char focus; while (scanf("%

找x-2010年哈尔滨工业大学计算机研究生机试真题

题目描述: 输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标(从0开始,若不在数组中则输出-1). 输入: 测试数据有多组,输入n(1<=n<=200),接着输入n个数,然后输入x. 输出: 对于每组输入,请输出结果. 样例输入: 2    1 3    0 样例输出: -1 解题代码: #include <stdio.h> int main(){ int n; int array[200]; while (scanf("%d"

2010年哈尔滨工业大学计算机研究生机试真题

题目连接:点击打开链接 解题思路: 简单暴力 完整代码: #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set> using namespace std; int n; int a[300]; bool check(int key) { set<int> s; s.clear(); for(int i =

2012年哈尔滨工业大学计算机研究生机试真题

题目连接:点击打开链接 解题思路: 模拟 完整代码: #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set> using namespace std; const int INF = 1000000000; const int maxn = 10001; char a[maxn] , b[maxn]; void MyS

判断三角形类型-2009年哈尔滨工业大学计算机研究生机试真题

题目描述: 给定三角形的三条边,a,b,c.判断该三角形类型. 输入: 测试数据有多组,每组输入三角形的三条边. 输出: 对于每组输入,输出直角三角形.锐角三角形.或是钝角三角形. 样例输入: 3 4 5 样例输出: 直角三角形 解题代码: #include <stdio.h> int main(){ int arr[3]; int temp; while (scanf("%d%d%d",&arr[0],&arr[1],&arr[2] ) != EO

九度机试 题目1165:字符串匹配 2008年北京航空航天大学计算机研究生机试真题

题目1165:字符串匹配 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2497 解决:858 题目描述: 读入数据string[ ],然后读入一个短字符串.要求查找string[ ]中和短字符串的所有匹配,输出行号.匹配字符串.匹配时不区分大小写,并且可以有一个用中括号表示的模式匹配.如"aa[123]bb",就是说aa1bb.aa2bb.aa3bb都算匹配. 输入: 输入有多组数据. 每组数据第一行输入n(1<=n<=1000),从第二行开始输入n个字符串(

考察数据类型的掌握---题目1166:迭代求立方根 (2009年北京航空航天大学计算机研究生机试真题)

题目描述: 立方根的逼近迭代方程是 y(n+1) = y(n)*2/3 + x/(3*y(n)*y(n)),其中y0=x.求给定的x经过n次迭代后立方根的值. 输入: 输入有多组数据.每组一行,输入x n. 输出: 迭代n次后的立方根,double精度,保留小数点后面六位. 样例输入: 3000000 28 样例输出: 144.224957 #include "stdio.h" int main(int argc, char* argv[]) {     long n;     dou

数据结构与算法问题 堆栈使用 2011年吉林大学计算机研究生机试真题

题目描述: 堆栈是一种基本的数据结构.堆栈具有两种基本操作方式,push 和 pop.Push一个值会将其压入栈顶,而 pop 则会将栈顶的值弹出.现在我们就来验证一下堆栈的使用. 输入: 对于每组测试数据,第一行是一个正整数 n,0<n<=10000(n=0 结束).而后的 n 行,每行的第一个字符可能是'P'或者'O'或者'A':如果是'P',后面还会跟着一个整数,表示把这个数据压入堆栈:如果是'O',表示将栈顶的值 pop 出来,如果堆栈中没有元素时,忽略本次操作:如果是'A',表示询问

2000年华中科技大学计算机研究生机试真题 阶乘

题目1179:阶乘 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4993 解决:1464 题目描述: 输入n,求y1=1!+3!+...m!(m是小于等于n的最大奇数)y2=2!+4!+...p!(p是小于等于n的最大偶数). 输入: 每组输入包括1个整数:n 输出: 可能有多组测试数据,对于每组数据,输出题目要求的y1和y2 样例输入: 4 样例输出: 7 26 来源: 2000年华中科技大学计算机研究生机试真题 #include <iostream> #include <