嵙大oj 2155 1236 1382 1607 1216 1214 2618


Problem IDTitle
Y2155 Problem A最高位是几?(Append Code)
Y1236 Problem BA+B Problem (X) : Pointer Practice (Append Code)
Y1382 Problem C编写函数:三个数的最大最小值 (Append Code)
Y1607 Problem D编写函数:有多少个数字 (Append Code)
Y1216 Problem E编写函数:字符串的复制 之二 (Append Code)
Y1214 Problem F编写函数:字符串的连接 之二 (Append Code)
Y2618 Problem G截取字符串

 2155

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
 
int high(int n)
{
    if((n/10)>0)
    {
        n/=10;
        high(n);
    }
    else
        return n;
}
int main()
{
    int data;
    scanf("%d", &data);
    printf("%d", high(data));
    return 0;
}

1236

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
 
 
int get_int_sum(int *a, int *b)
{
    scanf("%d %d",a,b);
    int c=*a+*b;
    return c;
}
int main()
{
    int n, a, b, i;
    scanf("%d", &n);
    for(i = 1; i <= n; i++)
    {
        printf("%d = ", get_int_sum(&a, &b));
        printf("%d + %d\n", a, b);
 
    }
    return 0;
}

1382

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
 
 
void get_num(int *a,int *b,int *c)
{
    scanf("%d %d %d",a,b,c);
}
max_min(int *mmax, int *mmin, int a,int b,int c)
{
     *mmax=a;
    if(b>*mmax)
        *mmax=b;
    if(c>*mmax)
        *mmax=c;
     *mmin=a;
     if(b<*mmin)
        *mmin=b;
    if(c<*mmin)
        *mmin=c;    
}
 
int main()
{
    int cases, i;
    int mmax, mmin, a, b, c;
 
    scanf("%d", &cases);
    for(i = 1; i <= cases; i++)
    {
        get_num(&a, &b, &c);
        max_min(&mmax, &mmin, a, b, c);
        printf("case %d : %d, %d\n", i, mmax, mmin);
    }
}

1607

#include<stdio.h>
#include<string.h>
 
 int get_nums(int *n)
 {
     int e;
     int len=0;
     while(scanf("%d",&e)!=EOF){
        len++;
     }
     *n=len;
     return len;
 }
 
 
int main()
{
    int n;
    get_nums(&n);
    printf("%d\n", n);
}

1216

#include <stdio.h>
 
#define MAX_STR_LEN 101
  
char * str_cpy(char * t, char * s, int n) {
    int i;
    for (i = 0; i < n && s[i] != '\0'; i++) {
        t[i] = s[i];
    }
    t[i] = '\0'; // 末尾添加结束符
    return t;
}
 
int main()
{
    int n;
    char s[MAX_STR_LEN], str[MAX_STR_LEN], *p;
    while(scanf("%d", &n) != EOF && getchar())
    {
        gets(s);
        p = str_cpy(str, s, n);
        puts(p);
        puts(str);
    }
    return 0;
}

1214

#include <stdio.h>
 
#include <ctype.h>
 
 
#define MAX_STR_LEN 101
 
char * str_cat(char * t, char * s, int n)
{
    int i=0,j=0;
    while(s[i]!='\0')
    {
        i++;
    }
    while(t[j]!='\0')
    {
        j++;
    }
    int lens=i+1;
    int lent=j+1;
//  printf("%d %d\n",lent,lens);
    if(lens<=n)
    {
        for(i=0;i<lens;i++)
        {
            t[lent-1+i]=s[i];
        }
        t[lent-1+i]='\0';
    }
    else
    {
        for(i=0;i<n;i++)
        {
            t[lent-1+i]=s[i];
        }
        t[lent-1+i]='\0';
    }
    return t;
}
 
 
int main()
{
    int n;
    char s[MAX_STR_LEN], str[MAX_STR_LEN], *p;
    while(scanf("%d", &n) != EOF && getchar())
    {
        gets(s);
        gets(str);
        p = str_cat(str, s, n);
        puts(p);
        puts(str);
    }
    return 0;
}

2618 

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
 

int main()
{
    char s[21]="\0";
    gets(s);
    int i;
    int len=strlen(s);
//  for(i=0;i<len;i++)
//  {
//      printf("%c",s[i]);
//  }
    int p,q;
    scanf("%d %d",&p,&q);
    if(p<0)
        p=0;
    if(q>(len-1))
        q=(len-1);
 
    printf("[");
    for(i=p;i<=q;i++)
    {
        printf("%c",s[i]);
    }
    printf("]");
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值