Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void nhap_mang(int a[], int &n)
- {
- cout << "Nhap so phan tu cua mang: ";
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cout << "Nhap phan tu arr[" << i + 1 << "] = ";
- cin >> a[i];
- }
- }
- void xuat_mang(int a[], int n)
- {
- for (int i = 0; i < n; i++)
- cout << "arr[" << i + 1 << "] = " << a[i] << endl;
- }
- void liet_ke(int a[], int n, int k)
- {
- for (int i = 0; i < n; i++)
- if (a[i] == k)
- cout << i << "\t";
- }
- void nhap_mang_2c(int a[][100], int &n, int &m)
- {
- cout << "Nhap n: ";
- cin >> n;
- cout << "Nhap m: ";
- cin >> m;
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cout << "arr[" << i << "][" << j << "] = ";
- cin >> a[i][j];
- }
- }
- }
- void xuat_mang_2c(int a[][100], int n, int m)
- {
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cout << a[i][j] << "\t";
- }
- cout << "\n";
- }
- }
- void main()
- {
- // khai bao mang a kieu int kich thuoc la 1000
- int arr[1000];
- // khai bao mang 2 chieu
- int arr2[100][100];
- // chi so mang trong c danh tu 0 di
- // n - 1 la chi so phan tu cuoi cung
- int n, m;
- nhap_mang_2c(arr2, n, m);
- xuat_mang_2c(arr2, n, m);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement