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 MyStrcat(char dstStr[] , char srcStr[])
{
    char c[maxn];
    int cnt = 0;
    for(int i = 0 ; dstStr[i] ; i ++)
        c[cnt++] = dstStr[i];
    for(int i = 0 ; srcStr[i] ; i ++)
        c[cnt++] = srcStr[i];
    c[cnt++] = '\0';
    for(int i = 0 ; c[i] ; i ++)
        printf("%c" , c[i]);
    cout << endl;
}

int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ
    while(cin >> a >> b)
    {

        MyStrcat(a , b);
    }
}

题目连接:点击打开链接

解题思路:

此题完全可以增加难度的,而且感觉题意表述有问题,陌生人向富翁谈计划,那第一句口吻应该是陌生人说的。。。。可是最后确是以富翁口吻来解题。

完整代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int INF = 1000000000;
const int maxn = 10001;

int main()
{
    long long sum = 1;
    long long k = 1;
    for(int i = 2 ; i <= 30 ; i ++)
    {
        k = k * 2;
        sum += k;
    }
    cout << "300 " << sum << endl;
}

题目连接:点击打开链接

解题思路:

这道题让我明白了九度上面时要用循环判断是否输入结尾才终止!!!

完整代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int INF = 1000000000;
const int maxn = 10001;

long long a[4][4] , b[4][4];
long long c[4][4];
int main()
{
    #ifdef DoubleQ
    freopen("in.txt" , "r" , stdin);
    #endif // DoubleQ

    while(cin >> a[0][0])
    {
        cin >> a[0][1] >> a[0][2] >> a[1][0] >> a[1][1] >> a[1][2];
        for(int i = 0 ; i < 3 ; i ++)
        {
            for(int j = 0 ; j < 2 ; j ++)
            {
                cin >> b[i][j];
            }
        }
        for(int i = 0 ; i < 2 ; i ++)
        {
            for(int j = 0 ; j < 2 ; j ++)
            {
                long long sum = 0;
                for(int k = 0 ; k < 3 ; k ++)
                {

                    sum += a[i][k] * b[k][j];
                }
                c[i][j] = sum;
            }
        }
        for(int i = 0 ; i < 2 ; i ++)
        {
            for(int j = 0 ; j < 2 ; j ++)
            {
                cout << c[i][j] << " ";
            }
            cout << endl;
        }
    }
}
 
时间: 2024-08-29 18:59:43

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

字符串去特定字符-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 =

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.t

判断三角形类型-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

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 <

题目1117:整数奇偶排序 (2008年北京大学图形实验室计算机研究生机试真题)

题目描述: 输入10个整数,彼此以空格分隔.重新排序以后输出(也按空格分隔),要求:1.先输出其中的奇数,并按从大到小排列:2.然后输出其中的偶数,并按从小到大排列. 输入: 任意排序的10个整数(0-100),彼此以空格分隔. 输出: 可能有多组测试数据,对于每组数据,按照要求排序后输出,由空格分隔. 样例输入: 4 7 3 13 11 12 0 47 34 98 样例输出: 47 13 11 7 3 0 4 12 34 98 提示: 1. 测试数据可能有很多组,请使用while(cin>>