实验9—指针1

#include<stdio.h>
int main(void)
{
    int i,j;
    int a[9][9];

    for(i=0;i<9;i++)
        for(j=0;j<9;j++)
            a[i][j]=(j+1)*(i+1);

        for(i=0;i<9;i++){
            for(j=0;j<9;j++)
                if(i>=j)
                printf("%d*%d=%d\t",j+1,i+1,a[i][j]);
                printf("\n");
        }

            return 0;
}

 

/****输入一行字符,统计数字,英文及其他字符的个数****/

#include<stdio.h>

void count(char *s,int *digit,int *letter,int *other)

{

         *digit=*letter=*other=0;

         while(*s!='\0'){

                   if(*s>='0'&& *s<='9')

                            (*digit)++;

                   else if(*s>'a'&& *s<'z')

                            (*letter)++;

                   else

                            (*other)++;

                   s++;

         }

}

int main()

{

         int i=0,digit,letter,other;

         char ch,str[80];

         printf("Enter charaters:");

         ch=getchar();

         while(ch!='\n'){

                   str[i]=ch;

                   i++;

                   ch=getchar();

         }

         str[i]='\0';

         count(str,&digit,&letter,&other);

         printf("digit=%d letter=%d other=%d\n",digit,letter,other);

 

         return 0;

}

 

 

/****判断输入的一串字符是否是"回文“****/

#include<stdio.h>

#include<string.h>

void main()

{

         char s[30];

         char *p,*q;

         int len, flag;

         gets(s);

         len=strlen(s);

         p=s;

         q=s+len-1;

         flag=1;

         while(p<q)

         {

                   if(*p==*q){

                            p++;

                            q--;

                   }

                   else{

                            flag=0;break;

                   }

         }

         if(flag)

                   printf("YES\n");

         else printf("No\n");

}

 

 

 

posted @ 2013-11-07 10:21  zhaoyang16  阅读(211)  评论(0编辑  收藏  举报