nhập N phần tử cho mảng A (nếu N < 100 thì yêu cầu nhập lại

nhập N phần tử cho mảng A (nếu N < 100 thì yêu cầu nhập lại

0 bình luận về “nhập N phần tử cho mảng A (nếu N < 100 thì yêu cầu nhập lại”

  1. #include<bits/stdc++.h>
    using namespace std;
    #define cls system(“cls”)
    void nhapmang(int *a, int &n)
    {
        int total=0;
        for (int i = 0; i<n; i++)
        {
            cout << “a[” << i << “]=”;
            cin >> *(a + i);
        }
    }
    int main()
    {
        int n;
        cin>>n;
        if(n<100){
            cls;
            return main();
        }
        int arr[n];
        nhapmang(arr,n);
        //samon247
        return 0;
    }

    Bình luận
  2. uses crt;
    var a : array[1..100] of integer;
    n,i : integer;
    begin clrscr;
    repeat write(‘Nhap so phan tu mang :’); readln(n);
    until n>100;
    for i:=1 to n do begin
    write(‘Nhap a[‘,i,’]=’); readln(a[i]); end;
    for i:=1 to n do write(a[i]:3);
    readln
    end.

    Bình luận

Viết một bình luận