杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》

杭电OJ(HDU)-ACMSteps-Chapter Two-《An Easy Task》《Buildings》《decimal system》《Vowel Counting》_第1张图片

http://acm.hdu.edu.cn/game/entry/problem/list.php?chapterid=1§ionid=2



1.2.5
#include<stdio.h>
/*
题意:找闰年。
 if((i%4==0 && i%100!=0) || i%400==0)count++;
 3
2005 25
1855 12
2004 10000
2108
1904
43236
*/
int main()
{
	int t,y,n;
	int i,count=0;
	while(scanf("%d",&t)==1)
	{
		while(t--)
		{		
			count = 0;
			scanf("%d%d",&y,&n);
			for (i=y;count<n;i++)
			{
				if((i%4==0 && i%100!=0) || i%400==0)
					count++;
			}
			printf("%d\n",i-1);
		}
	}
	return 0;
}

1.2.6
#include "stdafx.h"
/*
题意:计算每行1的个数
2
2 2
1 1
0 0
3 3
1 0 1
0 0 1
1 1 0

2
5
*/ 
#include <cstdio> 
#include <cstdlib> 
#include <stdio.h>  
int main(){  
	int n, m, z;  
	scanf("%d", &z);  
	int c=0;
	//int r=0,g=0;
	int *r;
	while (z-- != 0)
	{  
		scanf("%d%d", &n,&m);  
		while(n-- != 0)
		{
			r = (int*)malloc(sizeof(int)*m);
			for (int i = 0; i < m;++i)
			{
				scanf("%d",r+i);
				if (r[i] == 1)
					c++;
			}
		}
		printf("%d\n", c);     
		c = 0;
	}
	return 0;  
}  

1.2.7
#include<stdio.h>
/*
题意:转10进制做加法
3
1(2)
2(3)
3(4)

4
11(10)
11(2)
11(3)
11(4)

6
23
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int sum;

int pow(int x, int i)
{
    if(i == 0)
        return 1;
    else if(i == 1)
        return x;
    else 
        return x * pow(x, i - 1);
}

void fun(int x, int n)
{
    int i = 0, p;
    while(x) {
        p = x % 10;
        sum += p * pow(n, i);
        x = x / 10;
        i++;
    }
}  
int main( )
{
    int N, a,b, i;
    while(scanf("%d", &N)!=EOF) 
	{
		sum = 0;
		for(i = 1; i <= N; i++) 
		{
			scanf("%d(%d)",&a, &b);
			if (b == 10) 
			{
				sum += a;
				continue;
			}
			fun(a, b);
		}
		printf("%d\n",sum);
    }
    return 0;
}

1.2.8
/*
题意:元音词,数组映射,aAeEiIoOuU
4
XYz
application
qwcvb
aeioOa

xyz
ApplIcAtIOn
qwcvb
AEIOOA
*/
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
int alpha[256];
int main(){
    int n;
    char text[55];
    alpha['a']=alpha['A']=alpha['e']=alpha['E']=alpha['i']=alpha['I']=alpha['o']=alpha['O']=alpha['u']=alpha['U']=1;
    while(scanf("%d",&n)!=EOF){
        while(n--){
            scanf("%s",text);
            int len=strlen(text);
            for(int i=0;i<len;++i){
                if(alpha[text[i]]){
                    putchar(toupper(text[i]));
                }else{
                    putchar(tolower(text[i]));
                }
            }
            puts("");
        }
    }
    return 0;
}


 
 




你可能感兴趣的:(c,ACM,HDU,杭电,基本功)