Thứ Ba, 7 tháng 4, 2015

BWS: Task 6: INTRODUCTION TO JAVASCRIPT, FUNCTIONS, 'FOR' LOOPS IN JAVASCRIPT, 'WHILE' LOOPS IN JAVASCRIPT

I Lý Thuyết1. Introduction to javascript.- length: được dùng để đếm số ký tự trong một chuỗi hoặc đếm số phần tử trong một mảng..
-confirm() sẽ xuất hiện một thông báo popup nhưng nó có thêm hai sự lựa chọn là Yes và No, nếu người dùng chọn Yes thì nó trả về TRUE và ngược lại nếu chọn No thì nó sẽ trả về FALSE. Nó cũng có một tham số truyền vào và tham số này chính là nội dung thông báo.
Hàm prompt() dùng  để lấy thông tin từ người dùng, gồm có hai tham số truyền vào là nội dung thông báo và giá trị ban đầu. Nếu người dùng không nhập vào thì giá trị nó sẽ trả về là NULL.
Hàm console.log() : có thể được dùng để in giá trị của một biến.
- Trong javascript cũng có câu lệnh if, if/else và nó sử dụng như với môn C nếu ai đã học C.
Hàm substring() là hàm dùng để cắt chuỗi, nó sẽ có điểm bắt đầu cắt và điểm kết thúc.
- Cách gọi biến trong javascript: ta sẽ sử dụng từ khóa var để gọi biến. 
Ví dụ: 
-confirm() sẽ xuất hiện một thông báo popup nhưng nó có thêm hai sự lựa chọn là Yes và No, nếu người dùng chọn Yes thì nó trả về TRUE và ngược lại nếu chọn No thì nó sẽ trả về FALSE. Nó cũng có một tham số truyền vào và tham số này chính là nội dung thông báo.Hàm prompt() dùng  để lấy thông tin từ người dùng, gồm có hai tham số truyền vào là nội dung thông báo và giá trị ban đầu. Nếu người dùng không nhập vào thì giá trị nó sẽ trả về là NULL.Hàm console.log() : có thể được dùng để in giá trị của một biến.- Trong javascript cũng có câu lệnh if, if/else và nó sử dụng như với môn C nếu ai đã học C.Hàm substring() là hàm dùng để cắt chuỗi, nó sẽ có điểm bắt đầu cắt và điểm kết thúc.- Cách gọi biến trong javascript: ta sẽ sử dụng từ khóa var để gọi biến. Ví dụ: var myAge = 19;
2. Functions in.- Cách khai bái một hàm trong javascript như sau:Ví dụ:
var Huy = function(number) {};
- Trong đó Huy là tên hàm còn number là biến.
- Cách gán cho một biến: orangeCost(5); Lúc này biến orangeCost sẽ được gán giá trị là 5.
- Từ khóa return trong script cũng giống như C, nó sử dụng để trả lại các kết quả tính toán,
hay in chuỗi.
3. LOOPS IN JAVASCRIPT.
- Vòng lặp for, while, do while sử dụng đều giống như trong C.
Ví dụ for:
- Cách gán cho một biến: orangeCost(5); Lúc này biến orangeCost sẽ được gán giá trị là 5.

- Từ khóa return trong script cũng giống như C

, nó sử dụng để trả lại các kết quả tính toán,hay in chuỗi.3. LOOPS IN JAVASCRIPT.

- Vòng lặp for, while, do while sử dụng đều giống như trong C.Ví dụ for:
for (var counter = 1; counter < 11; counter++) { console.log(counter);}
Ví dụ: while:
while (condition) {          code;}
Ví dụ do..while:
do {      code;}while(condition);
- để in ra phần tử thứ 2 ra màn hình ta sử dụng console.log: console.log(bluesky[3]);Hàm Math.random(): dùng để tạo giá trị ngẫu nhiên từ 0 đến 1. Để tạo xác suất ngẫu nhiên theo %, có thể sử dụng (Math.random() * 100).- Hàm Math.floor(): dùng để làm tròn giá trị.

II -Thực hành

Thứ Năm, 2 tháng 4, 2015

I.Ly Thuyet
 -FORM là một mẫu văn bản dùng để thu thập thông tin, chẳng hạn như hồ sơ xin việc làm, mẫu  thăm dò ý kiến được viết ở phần body.
-Câu lệnh:trong thẻ  form chúng ta  bắt   đầu  từ  <input>  để  nhập   dữ  liệu  đầu  vào  ,trong  thẻ  <input> có  các  thẻ  khác  như   type="kiểu dữ  liệu"
vd:chúng  ta  muốn  nhập  chữ là:type="text";
      -với   số  :type="number"
       -email: type="email".............
-Câu lệnh : placeholder giúp   hiển  thị   gợi ý  của   form ,để người  sử  dụng  dễ  dàng  hiểu  được cần  nhập dữ liệu  đúng nào  vào .                              
II.Thuc Hanh

Chủ Nhật, 29 tháng 3, 2015

CSS CLASSES AND IDS và CSS ELEMENT POSITIONING

I.Lý Thuyết
ID-ClASS
Class và Id là hai thành phần vô cùng quan trọng trong css. Nó giúp cho việc định dạng một hoặc một tập hợp các thẻ html có chung những thuộc tính như màu sắc, kích thước hay cỡ chữ... trở nên nhanh hơn và hiệu quả hơn. Việc sử dụng class và id trong css còn giúp cho việc quản lý codecss trở nên dễ dàng hơn.

-  ID được sử dụng cho các thành phần mang tính tuyệt đối và duy nhất trong toàn bộ trang web

- Class  được gán cho các thành phần sẽ lặp lại nhiều lần. Việc gán class cho nhiều thành phần của trang web thì bạn chỉ việc khai báo style trên file CSS cho các thành phần này một lần duy nhất.

Ví dụ :
#vidu{

  width: 80%;

  padding: 20px;

  border: 1px solid #666;



}


.vidu2{

  font-size: small;

  color: #008080;

  font-weight: bold;

}

CSS ELEMENT POSITIONING:

-Static
•Định vị với giá trị static là cách mặc định mà một phần tử sẽ xuất hiện trong tài liệu (X)HTMl của bạn. Kể cả khi bạn không khai báo position cho phần tử thì mặc định nó vẫn có giá trị static.
(position: static;)
-Relative
•Định vị một phần tử với vị trí tương đối và sau đó bạn có thể tùy chỉnh lại vị trí của nó với các thuộc tính left, right, top, bottom.
(position: relative;)
-Absolute

•Định vị một phần tử tách biệt hẳn so với tài liệu (X)HTMl của bạn. Nếu như một phần tử được định vị với giá trị là absolute được đặt trong một phần tử khác được định vị với giá trị khác static, nó sẽ được định vị tại top left của phần tử cha, nếu không, nó sẽ được định vị tại top left của cửa sổ trình duyệt
(position: absolute;)
-Fixed
•Định vị một phần tử với giá trị fixed gần giống với giá trị absolute, trừ việc nó sẽ luôn được căn chỉnh với cửa sổ trình duyệt.
II-Bài Tập

Thứ Ba, 24 tháng 3, 2015

CSS I

I. Lí thuyết.

1) Inline css:
- Viết các thuộc tính quy định luôn trong attribute style.
- Không có khả năng reuse. Viết code nhiều.
- Khi chỉ muốn thay đổi đúng 1 thẻ html, thì sẽ sử dụng inline css.
Ví dụ: 
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>
2) Embbeb css.
- Viết luôn css trong phần head của file html.
- Phạm vi sử dụng là trong 1 file html
Ví dụ:
<head>
<style>body {    background-color: linen;}h1 {    color: maroon;    margin-left: 40px;} </style></head>

3)External css.
- Css được viết ra trong 1 file riêng.
- Có thể sử dụng lại tại nhiều trong html trong cùng wed.
- Muốn sử dụng lại css thì đưa link liên kết.
Ví dụ:
<link href=”Blue Sky.css” type=”text/css” rel=”stylesheet” />
Trong đó: href: địa chỉ file css(thay đổi tùy vào wed).
                 type=”text/css” loại dữ liệu là text và css (giữ nguyên).

                 rel=”stylesheet” loại áp dụng là thẻ quy định đặc điểm (giữ nguyên).
II.Thực hành

Thứ Năm, 19 tháng 3, 2015

Bài Tập Ngày 2

I-Lý Thuyết
<ol></ol> được sử dụng để tạo ra một danh sách có thứ tự
<ul></ul> được sử dụng để tạo ra một danh sách  không có số thứ tự
2 cấu trúc này đều được thực hiện bởi cấu trúc con <li></li>
VD:
<ol> 
               <li>1</li>
               <li>2</li>
            </ol>
__________
<ul> 
               <li>3</li>
               <li>4</li>
            </ul>


<!-- --> Sử dụng để comment
-style="font-size: " Thay đổi kích cỡ của chữ

VD: <p style="font-size:12px">Nguyễn Trọng Huy</p>
-style="font-family: " Thay đổi phông chữ cho đoạn văn

VD: <p style="font-family:Impact">Nguyễn Trọng Huy</p>
-style="color: "đổi màu chữ

VD: <p style="color:blue">Nguyễn Trọng Huy</p>
-style="text-align:" Chọn vị trí cho văn bản, có thể trái phải giữa
-background-color: Đổi màu nền cho khung ta lựa chọn
-<strong></strong> in đậm 1 từ 1 chữ hoặc 1 đoạn văn
-<em></em> nghiêng 1 chữ hoặc 1 đoạn văn
<table></table> Tạo bảng
<tr></tr>  Tạo cột cho bảng
<th></th> Tạo Tiêu đề cho bảng
<td></td>Cập nhật nội dung cho bảng
<span></span> đánh dấu 1 đoạn văn hoặc 1 từ

II-Thực Hành

Thứ Tư, 18 tháng 3, 2015

I.Khái niệm.
-HTML gọi là "ngôn ngữ đánh dấu siêu văn bản" được sử dụng chủ yếu để tạo nội dung, hình ảnh cho một website và thiết kế cho nó.
-Thành phần của một trang HTML bao gồm các liên kết, hình ảnh hoặc các nút dẫn tới link, ảnh, bảng thống kê.
 
II.Cấu trúc.
-Văn bản HTML bao gồm các thẻ mang từ khóa đc gói trong một cặp dấu "<'từ khóa'>" và các thẻ được thực hiện khi gồm thêm một cặp </'từ khóa'> nữa.
-Mở đầu nội dung văn bản HTML luôn là thẻ <html> và kết thúc là thẻ </html>
-Trước thẻ <html> còn có thể có <!DOCTYPE html> nhưng đây không phải là một thẻ trong cấu trúc, nó chỉ là chỉ dẫn phiên bản html được sử dụng.


  • Mọi trang web mà bạn nhìn thấy đều được viết trên ngôn ngữ gọi là HTML. Bạn có thể hiểu rằng HTML như một bộ xương cấu trúc lên một website.
  • Trong khóa học này, chúng ta sẽ dùng HTML để thêm đoạn văn bản, tiêu đề, hình ảnh và địa chỉ liên kết.
  • Phần chỉnh sửa bên phải, có một tab gọi là test.html. Đây là thư mục chúng ta sẽ điền HTML vào. Có thể thấy dòng code với dấu <>s? Đó chính là HTML!
  • Như những ngôn ngữ khác, nó có cú pháp đặc biệt riêng ( quy tắc để giao tiếp ).
  • HTML viết tắt của HyperText Markup Language. HyperText có nghĩa là "chữ có liên kết bên trong". Bất kể khi nào bạn kích vào những chữ đó, nó sẽ đưa bạn đến trang web mới.
  • Markup Language là một chương trình ngôn ngữ đc sử dụng để làm văn bản có thể làm nhiều việc hơn. Nó có thể chuyển văn bản thành hình ảnh,liên kết, bảng, mục, và nhiều hơn nữa. HTML là ngôn ngữ đánh dấu chúng ta sẽ học.
  • Điều gì làm cho website trở nên đẹp đẽ hơn? Đó chính là CSS-Cascading Style Sheets.Nó như là làn da và trang điểm cho bìa của bộ xương HTML. Chúng ta sẽ học HTML trước, xong rồi lo đến CSS tại khóa sau.

Thứ Ba, 10 tháng 2, 2015

Bài 6.1

I.Lý Thuyết

II.Bài Tập

1. Write a C program that accepts a number and square the number with the help of a function.
To do this,
a. Declare a function.
b. Accept the number.
c. Pass the number to the function and return the square of that number

Function prototype: int cal_square(int number);

2. Write a C program to find the area and perimeter of a circle.
Function prototype: float areaCircle(float radius);
Function prototype: float perimeterCircle(float radius);

Using the library: “Math.h” => PI = 3.14

3. Write a C program to calculate the factorial of an integer
Function prototype:  long factorial(int number);

4. Write a program with a function that takes two int parameters, adds them together, then returns the sum. The program should ask the user for two numbers, then call the function with the numbers as arguments, and tell the user the sum.
Function prototype: int calSum(int number1, int number2);
 Bài Làm :
 
Bài 1: 

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int S(int a);

int main(int argc, char *argv[]) {
    int x =4;

    int sub(x);
    printf("S=%d",S(x));
    return 0;
   
}
int S(int a){
    int S=a*a;
    return S;
}
 Bài 2
#include <stdio.h>
#include <stdlib.h>
#define PI 3.14
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
float C(float x);
float S(float x);
int main(int argc, char *argv[]) {
    float R;
    printf("Nhap Ban Kinh R =");
    scanf("%f",&R);
    float a = C(R);
    float b =S(R);
    printf("Chu Vi Hinh Tron = %f",a);
    printf("\nDien tich Hinh Tron = %f",b);
    return 0;
}
float S(float x){
    float S=PI*x*x;
    return S;
}
float C(float x){
    float C=2*PI*x;
    return C;
}
Bài 3

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int GiaiThua(int T);
   

int main(int argc, char *argv[]) {
    int S;
    printf("Nhap Mot So :");
    scanf("%d",&S);
    int C = GiaiThua(S);
    printf("%d ! = %d",S,C);
   
    return 0;
}
int GiaiThua(int T){
    int a=1;
    int b=1;
    for(;a<=T;a++){
        b=b*a;
    }
    return b;
}
Bài 4
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int Tong(int ,int );
   

int main(int argc, char *argv[]) {
    int s;
    printf("Nhap So :");
    scanf("%d",&s);
    int f;
        printf("Nhap So :");
        scanf("%d",&f);
    printf("Tong = %d",Tong(s,f));
   
    return 0;
}
int Tong(int s, int f){
   

     int t;
     t= s+f;

 return t;
}

6.3


1. Viết hàm truyền vào 2 số nguyên bất kỳ, thực hiện đổi chỗ 2 số đó
Nguyên mẫu hàm như sau:
void swap (int &number1, int &number2);

2. Viết hàm truyền vào một mảng số nguyên bất kỳ, sau đó đảo ngược mảng số nguyên đó
void reverse(int array[]);

3. Viết hàm truyền vào một mảng ký tự, và một ký tự bất kỳ, kiểm tra xem ký tự bất kỳ đó có nằm trong mảng không. Nếu có trả về số lần xuất hiện của ký tự đó, nếu không trả về -1
int countCharacter(char array[], char ch);


Bài làm

Bài 1.

#include <stdio.h>
#include <stdlib.h>
void s (int *x, int *y);
int main(int argc, char *argv[]) {
    int x,y;
 printf (" Nhap So : ");
scanf("%d",&x);
printf (" Nhap So : ");
 scanf("%d",&y);
 s(&x,&y);
 printf("Hoan Vi. : %d  %d",x,y);

 return 0;
}
void s (int *x, int *y){
 int z = x;
 x = y;
 y = z;
}

Bài 2
#include <stdio.h>
#include <stdlib.h>

void reverse(int array[10]);

int main(int argc, char *argv[]) {
 int So[10],i;
 for(i=0;i<10;i++) {
 printf("So[%d]=",i+1);
 scanf("%d",&So[i]);
 }
 reverse(So);
}
void reverse(int array[10]) {
 int i;
 for(i=9;i>=0;i--) {
  printf("\n%d",array[i]);
 }
 return reverse;
}


6.2

Bài Tập

1. Write a function which accepts an integer value as input, and returns an integer which is the cube of that input

2. Write a function that accepts a char as input and returns true if the char is a digit from 0 to 9 or false if the character is not a digit from 0 to 9

3. Write a function named Smallest that takes three integer inputs and returns an integer that is the smallest of the three inputs.  Write the prototype for the Smallest function.  Write  a program that gets 3 integers from a user and displays the smallest.

4. Write a function that, given a letter of the alphabet, returns true if the letter is a vowel (lower or uppercase) and returns false if the letter is not a vowel.
Bài Làm

Bài 1
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int LapPhuong(int );
   

int main(int argc, char *argv[]) {
    int A;
    printf("Nhap So :");
    scanf("%d",&A);
   
    printf("Lap Phuong = %d",LapPhuong(A));
   
    return 0;
}
int LapPhuong(int A){
   

     int t;
     t= A*A*A;

 return t;
}

Bài 2
 #include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
char A(char );
   

int main(int argc, char *argv[]) {
    char B;
    printf("Nhap Mot Ki Tu :");
    scanf("%c",&B);
   
if(B>='0'&&B<='9')    {
    printf("True");
}
else printf("False");
   
    return 0;
}
char A(char B ){

if(B>=0&&B<=9)   
   

 return B;
}

Bài 3.
 #include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int A(int,int,int );
   

int main(int argc, char *argv[]) {
    int a,b,c;
    printf("Nhap So :");
    scanf("%d",&a);
    printf("Nhap So :");
    scanf("%d",&b);
    printf("Nhap So :");
    scanf("%d",&c);
    printf("So nho nhat trong 3 So la :%d",A(a,b,c));
    return 0;
}
int A(int a,int b, int c ){

int i=a;
if(i>b) i=b;
if(i>c) i=c;
   

 return i;
}

Bài 4
 #include <stdio.h>
#include <stdlib.h>
/* Write a function that, given a letter of the alphabet,
returns true if the letter is a vowel (lower or uppercase) and returns false if the letter is not a vowel. */
int N(char);
int main(int argc, char *argv[]) {
     char x;
 printf ("Nhap Chu: ");

 scanf("%c",&x);
 if (N(x)) printf ("%c =Nguyen Am",x);
  else printf ("%c K lA Nguyen Am",x);


 return 0;
}
int N(char x){
 int N;
 if (x=='u'||x=='U'||x=='e'||x=='E'||x=='o'||x=='O'||x=='a'||x=='A'||x=='i'||x=='I') N= 1;
  else N=0;
 return N;
}

Thứ Năm, 5 tháng 2, 2015

Bài 5.1

I.Lý Thuyết
Cấu trúc :
*Cú pháp: <Kiểu> <Tên mảng ><[số phần tử]>
- Tên mảng: đây là một cái tên đặt đúng theo quy tắc đặt tên của danh biểu. Tên này
cũng mang ý nghĩa là tên biến mảng.
- Số phần tử: là một hằng số nguyên, cho biết số lượng phần tử tối đa trong mảng là
bao nhiêu (hay nói khác đi kích thước của mảng là gì).
- Kiểu: mỗi phần tử của mảng có dữ liệu thuộc kiểu gì.

*Mảng :Mảng là một dãy các phần tử có cùng kiểu được đặt liên tiếp trong bộ nhớ và có thể truy xuất đến từng phần tử bằng cách thêm một chỉ số vào sau tên của mảng. 
II.Bài Tập
Bài 1 : Write a program that asks the user to type 10 integers of an array. The program must compute and write how many integers are greater than or equal to 10.
 

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
        int A[10];
        int n;
        int C=0;
        for(n=0;n<10;n++){
            printf("Nhap A[%d]=",n+1);
            scanf("%d",&A[n]);
        }
        printf("\n Cac so trong lon hon = 10 trong day :");
        for(n=0;n<10;n++){
           
            if(A[n]>=10){
                printf("%d ",A[n]);
            C=C+1;
       
       
        }
       
    }

   
    return 0;
}
Bài 2 :Write a program that asks the user to type 10 integers of an array. The program must output the largest element in the array, and the index at which that element was found.

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
        int A[10];
        int n;
       
        for(n=0;n<10;n++){
            printf("Nhap A[%d]=",n+1);
            scanf("%d",&A[n]);
        }
      
        int max=A[0];
        
        for(n=0;n<10;n++){
           
            if(A[n]>max){
           
            max=A[n];
       
       
        }
       
       
    }
printf("Max=%d",max);
for(n=0;n<10;n++){
    if(A[n]==max)
    printf("\nVi tri=%d",n+1);
}
   
    return 0;
}
Bài 3:Input values are accepted from the user into the array. Displays highest of the entered values. Prints average of values entered.
#include <stdio.h>

#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
     int A[5];
     int i;
     for(i=0;i<5;i++){
         printf("Nhap A[%d]=",i+1);
         scanf("%d",&A[i]);
     }
     int max=A[0];
     for(i=0;i<5;i++){
         if(A[i]>max){
             max=A[i];
         }
     }
     printf("Max=%d",max);
     int t;
     for(i=0;i<5;i++){
         t=t+A[i];
     }
     printf("\nTrung Binh Cong =%d",t/i);
        return 0;

}

Bài 4 Write a program that accepts the following numbers in an array and reverses the array
#include <stdio.h>
#include <stdlib.h>

/* Write a program that accepts the following numbers in an array and reverses the array */

int main(int argc, char *argv[]) {
 int t;
 printf("So Luong  Gia Tri Trong Mang= ");
 scanf("%d",&t);
 int A[t],B[t],i;
 for (i=0;i<t;i++){
  printf("A[%d]= ", i+1);
  scanf("%d",&A[i]);
B[t-i-1] = A[i];                                                                                                                                          
 }

 for (i=0;i<t;i++) printf("\n\tA[%d]= %d\t",i+1,A[i]);

 for (i=0;i<t;i++) printf("\nB[%d]= %d\t",i+1,B[i]);
 return 0;
}


Bài 5
. Write a program to count the number of vowels in a line of text
Bài 6 :
Write a program that asks the user to type 10 integers of an array and an integer V. The program must search if V is in the array of 10 integers. The program writes "V is in the array" or "V is not in the array".

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
int A[10];
int i;
for(i=0;i<10;i++){
printf("A[%d]=",i+1);
scanf("%d",&A[i]);
}
int V;
printf("Nhap V =");
scanf("%d",&V);
int d;
d=0;
for(i=0;i<10;i++)

if(V==A[i])
d=1;
if(d==1)
printf("V co trong mang");

else printf("V khong co trong mang");


return 0;
}

Bài 7 :
Write a program that asks the user to type 10 integers of an array and an integer value V. The program must search if the value V exists in the array and must remove the first occurrence of V, shifting each following element left and adding a zero at the end of the array. The program must then write the final array

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    int A[10];
    int i;
    for(i=0;i<10;i++){
        printf("A[%d]=",i+1);
        scanf("%d",&A[i]);
    }
    int V;
    printf("Nhap V =");
    scanf("%d",&V);
for(i=0;i<10;i++) if(V==A[i]) break;
 for (i;i<10;i++) A[i]=A[i+1];
 A[9]=0; printf("\n\n\n");
 for (i=0;i<10;i++) printf("%d  ",A[i]);

    return 0;
}
Bài 8 :
Write a program that asks the user to type 10 integers of an array and an integer value V and an index value i between 0 and 9. The program must put the value V at the place i in the array, shifting each element right and dropping off the last element. The program must then write the final array



#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    int A[10];
    int j;
    for(j=0;j<10;j++){
        printf("A[%d]=",j+1);
        scanf("%d",&A[j]);
    }
    int V,i;
    printf("Nhap V =");
    scanf("%d",&V);
    printf("Nhap i =");
    scanf("%d",&i);
    for(j=9;j>i;j--)
    A[i]=V;
    printf("final array :");
    for(j=0;j<10;j++)
    printf("\t%d",A[j]);
    return 0;
}

Bài 9 :
Write a program that asks the user to type 10 integers of an array. The program will then display either "the array is growing", "the array is decreasing", "the array is constant", or "the array is growing and decreasing."

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    int A[10];
    int j,i,m,n;
    for(j=0;j<10;j++){
        printf("A[%d]=",j+1);
        scanf("%d",&A[j]);
    }
    i=m=n=0;
    for(j=0;j<9;j++){
   
    if(A[j]==A[j+1])
    i=i+1;
    if(A[j]>A[j+1])
    m=m+1;
    if(A[j]<A[j+1])
    n=n+1;
}
if(i==9){
printf("Mang lien tuc");}
else if(m==9){
    printf("Mang dang giam");
}
else if(n==9){
    printf("Mang dang tang");
}
else printf("Mang vua tang vua giam");
    return 0;
}

Bài 10 :
10. Write a program that asks the user to type 10 integers of an array. The program will then sort the array in descending order and display it.

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
 int A[10],i,a,b;
 for(i=0;i<10;i++) {
  printf("A[%d]:",i+1);
  scanf("%d",&A[i]);
 }
 for(i=0;i<10;i++) {
  for(a=0;a<10;a++) {
   if(A[a]>A[a-1]) {
   b=A[a-1];
   A[a-1]=A[a];
   A[a]=b;
   }
  }
 }
 for(i=0;i<10;i++) {
  printf("%d ",A[i]);
 }
 return 0;
}

Bài 11 :
11. Write a program which takes 2 arrays of 10 integers each, a and b. c is an array with 20 integers. The program should put into c the appending of b to a, the first 10 integers of c from array a, the latter 10 from b. 




include <stdio.h>
#include <stdlib.h>

/* Write a program which takes 2 arrays of 10 integers each, a and b.
c is an array with 20 integers. The program should put into c the appending of b to a,
the first 10 integers of c from array a, the latter 10 from b. Then the program should display c */

int main(int argc, char *argv[]) {
 int A[20],i;
 for(i=0;i<10;i++){
  printf("A[%d]=",i+1);
  scanf("%d",&A[i]);
 } 
 for(i=10;i<20;i++){
  printf("B[%d]=",i-9);
  scanf("%d",&a[i]);
 } 
 for(i=0;i<20;i++) printf("C[%d]=%d\t",i+1,a[i]);
 printf("\n\n\n");
 system("pause");
 return 0;
}