欢迎使用CSDN-markdown编辑器

试题编号: 201503-1
试题名称: 图像旋转

#include<iostream>
using namespace std;
int main()
{
    static int a[1000][1000];//不加static也可以欸~~~
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    for(int i=m-1;i>=0;i--)
    {
        for(int j=0;j<n;j++)
            cout<<a[j][i]<<" "; 
        cout<<endl; 
    }    
    return 0;
}

试题编号: 201503-2
试题名称: 数字排序

#include<iostream>
#include<algorithm>
using namespace std;
struct num
{
<span style="white-space:pre">  </span>int val;
<span style="white-space:pre">  </span>int time;
}a[1005];


bool cmp(num x,num y)
{
<span style="white-space:pre">  </span>if(x.time!=y.time)
<span style="white-space:pre">  </span>return x.time>y.time; 
<span style="white-space:pre">  </span>else
<span style="white-space:pre">  </span>return x.val<y.val;
<pre name="code" class="cpp">//<span>   </span>return x.time>y.time||(x.time=y.time&&x.val<y.val); 不可以
}


int main()
{
<span style="white-space:pre">  </span>int n;
<span style="white-space:pre">  </span>cin>>n;
<span style="white-space:pre">  </span>for(int i=0;i<1005;i++)//初始化不能初始为n;
<span style="white-space:pre">  </span>{
<span style="white-space:pre">      </span>a[i].val=i;
<span style="white-space:pre">      </span>a[i].time=0;
<span style="white-space:pre">  </span>}
<span style="white-space:pre">  </span>for(int i=0;i<n;i++)
<span style="white-space:pre">  </span>{
<span style="white-space:pre">      </span>int tmp;
<span style="white-space:pre">      </span>cin>>tmp;
<span style="white-space:pre">      </span>a[tmp].time++;
<span style="white-space:pre">  </span>}
<span style="white-space:pre">  </span>sort(a,a+1005,cmp);
<span style="white-space:pre">  </span>for(int i=0;i<n;i++)
<span style="white-space:pre">  </span>{
<span style="white-space:pre">      </span>if(a[i].time==0) break;
<span style="white-space:pre">      </span>cout<<a[i].val<<" "<<a[i].time<<endl;
<span style="white-space:pre">  </span>}
<span style="white-space:pre">  </span>return 0;
}

试题编号:201412-1
试题名称:门禁系统
#include

#include<algorithm>
using namespace std;

int main()
{
    int n,x;
    cin>>n;
    static int arr[1005];
    for(int i=0;i<n;i++)
    {
        cin>>x;
        arr[x]++;
        cout<<arr[x]<<" ";
    }`这里写代码片`
    return 0;
}

试题编号: 201412-2
试题名称: Z字形扫描

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int arr[505][505];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>arr[i][j];
    int x,y;
    x=0;y=0;
    int i=0;
    while(!(x==n-1&&y==n-1))
    {
        //i++;
        cout<<arr[x][y]<<" ";
        if((x==0&&y!=(n-1)&&(y%2==0))||(x==(n-1)&&(y%2==n%2)))
        {
            y++;
        }
        else if((y==0&&x!=(n-1)&&(x%2==1))||(y==(n-1)&&(x%2!=n%2)))
        {
            x++;
        }
        else if((x+y)%2==1)
        {
            x++;y--;
        }
        else if((x+y)%2==0)
        {
            x--;y++;
        }
    }
    cout<<arr[x][y]<<" ";
    return 0;
}

201409-3
试题名称: 字符串匹配

#include<iostream>
#include<string>
#include<cstring>
#include<ctype.h>
using namespace std;

string tolow(string s)
{
    string rs=s;
    char *p=const_cast <char*> (s.c_str());
    while(*p!='\0')
    {
        *p=tolower(*p);
        p++;
    }
    return rs;
}

int main()
{
    string ss;
    string s;
    cin>>ss;
    int op,n;
    cin>>op>>n;

    for(int i=0;i<n;i++)
    {
        cin>>s; 
        if(op==0)
        {   
            if(strstr(tolow(s.c_str()).c_str(),tolow(ss.c_str()).c_str()))
                cout<<s<<endl;
        }
        else if(strstr(s.c_str(),ss.c_str()))
                cout<<s<<endl;
    }

    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值