IT STUDENT
Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Viết chương trình cho phép đảo mảng vừa nhập

Go down  Message [Page 1 of 1]

Admin


Admin

code:
#include<stdio.h>
#include<conio.h>
int main(){
   //cap phat mang dong co 10 phan tu.
   char *a,ch,*p,*q;
   int i;
   a=(char*)malloc(10);
    for(i=0;i<10;i++){
    //nhap vao gt cho cac phan tu
    printf("a[%d]=",i);
    scanf("%c", (a+i));
    fflush(stdin);  
    }
    //dao mang vua nhap
    p=a;
    q=(a+9);
    while(p<q){
        ch=*p;
        *p=*q;
        *q=ch;
        p++;
        q--;
    }
    for(i=0;i<10;i++){
        printf("%c",*(a+i));
    }
    getch();
}

https://itstudent-pnv.board-directory.net

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum