KTLT-Chude1

Embed Size (px)

Citation preview

  • 8/8/2019 KTLT-Chude1

    1/5

    1. TM KT QU THC HIN CHNG TRNH2. CHUYN I CHNG TRNH

    1. Hy cho bit kt qu thc hin on chng trnh di y.

    2. Hy cho bit kt qu thc hin on chng trnh di y.

    #include #include int A[] = {19, 12, 18, 13, 10, 14, 16, 11, 15, 17}, n=10, count=0;

    void Result(int *A, int n){count++; printf("\n Buoc %d:",count);for(int i=0; i

  • 8/8/2019 KTLT-Chude1

    2/5

    3. Hy cho bit kt qu thc hin on chng trnh di y.

    4. Hy cho bit kt qu thc hin on chng trnh di y:

    #include #include int A[] = {19, 12, 18, 13, 10, 14, 16, 11, 15, 17}, n=10, count=0;void Result(int *A, int n){

    count++; printf("\n Ket qua buoc %d:",count);for(int i=0; i A[j]){

    temp = A[j-1]; A[j-1] = A[j]; A[j] = temp;}

    }Result(A,n);

    } getch();}

    #include #include int B[]={0,0,0,0,0}, n=5, OK=1, count=0;void Result(void){

    printf("\n Ket qua buoc %3d:",++count);for (int i=0; i=0 && B[i]; i--)B[i] =0;

    if(i>=0) B[i]=1;else OK=0;

    }void main(void){

    do {Result();Function1();

    } while(OK);}

  • 8/8/2019 KTLT-Chude1

    3/5

  • 8/8/2019 KTLT-Chude1

    4/5

    7. Hy cho bit kt qu thc hin on chng trnh di y.

    8. Hy cho bit kt qu thc hin on chng trnh di y.

    #include #include int B[]={0,0,0,0,0,0,0}, n=7,k=80, OK=1, count=0;int A[]={5,10,15,20,25,30,35};void Inketqua(void){

    printf("\n Ket qua %3d:",++count);for(int i=0; i=0) B[i]=1;else OK=0;

    }void main(void){

    do {Result();Function1();

    } while(OK);}

    #include #include int B[]={0,0,0,0,0,0,0}, n=7,k=40, OK=1, count=0;int A[]={5,10,15,20,25,30,35};void Inketqua(void){

    printf("\n Ket qua %3d:",++count);for(int i=0; i

  • 8/8/2019 KTLT-Chude1

    5/5

    9. Hy cho bit kt qu thc hin on chng trnh di y.

    10. Hy cho bit kt qu thc hin on chng trnh di y.

    11.

    a) Chng minh rng mt chng trnh c th hin bng tt c cc cu trc lnh (while,do..while, for, if..else, switch) u c th chuyn i thnh mt chng trnh mi cho likt qu ging nh chng trnh c nhng ch cn dng ti thiu cu trc lnh lp whilev mt s bin ph.

    b) p dng kt qu trn chuyn i cc chng trnh t bi 1 n bi 10 s dng ti thiucu trc lnh lp while v mt s bin ph.

    #include #include #include char str[255]="000 001 010 011 100 101 110 111 101 110";void main(void){ clrscr();

    int n, m=0, k=0;n = strlen(str);char s[32];for(int i=0; i0) {s[k]='\0';m++;k=0;printf("\n Kt qu bc %d:

    %s",m,s);}break;

    default:s[k++]=str[i]; break;

    }

    }}

    #include #include #include int nguyen_to(unsigned long int n){

    unisened long int i, k=sqrt(n);for(i=2; i