码迷,mamicode.com
首页 > 其他好文 > 详细

第九次作业

时间:2016-11-23 22:52:56      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:i++   ring   --   作业   input   blog   getch   dex   stdio.h   

#include<stdio.h>
int main(void)
{
    int i,j,n,temp;
    int a[6][6];
    printf("Enter n:");
    scanf("%d",&n);
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            a[i][j]=i*n+j+1;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
            if(i<=j){
                temp=a[i][j];
                a[i][j]=a[j][i];
                a[j][i]=temp;
            }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++)
            printf("%4d",a[i][j]);
        printf("\n");
}
    return 0;                
            
}
#include<stdio.h>
int main(void)
{
    int i,j;
    int a[10][10];

    for(i=1;i<10;i++){  
        for(j=1;j<=i;j++){
            a[i][j]=i*j;
            printf("%d*%d=%d\t",i,j,a[i][j]); 
        }
        printf("\n");
    }
    return 0;
}
#include<stdio.h>
int main(void)
{
    int i,k,temp; 
    char str [80];
    int n;
    printf("enter a str:");
    i=0;
    while((str[i]=getchar())!=\n)i++;
    str[i]=\0;
    k=i-1;
    for(i=0;i<k;i++) {
        temp=str[i];
        str[i]=str[k];
        str[k]=temp;
        k--;
    }
    for(i=0;str[i]!=\0;i++)
    putchar(str[i]);
    return 0;
}
#include<stdio.h>
int main(void)
{
    int i=0,k=0,flag=0;
    char str[80],m;
    printf("input a character:");
    scanf("%c",&m);
    printf("input a string:");
    getchar();
    while((str[i]=getchar())!=\n)
        i++;
        str[i]=\0;
    for(i=0;str[i]!=\0;i++){
        if(str[i]==m)k=i;
             flag=1;    
   }
    if(flag==1)
        printf("index=%d\n",k);
        else printf("not found!\n");
     return 0;
    
    
}

 

第九次作业

标签:i++   ring   --   作业   input   blog   getch   dex   stdio.h   

原文地址:http://www.cnblogs.com/16-C-kai/p/6095448.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!