Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<iostream>
- using namespace std;
- int a[100];
- void main()
- {
- int i,n,max,min;
- cout<<"Nhap vao so phan tu cua mang: "<<endl;
- cin>>n;
- for (i=0; i < n; i++)
- {
- cout << "Nhap vao phan tu thu " << i + 1 << ": ";
- cin >> a[i];
- }
- max=a[0];
- min=a[0];
- for (i=0; i < n; i++ )
- {
- if (min > a[i]) min = a[i];
- if (max < a[i]) max = a[i];
- }
- cout << " Phan tu nho nhat la: " << min << endl;
- cout << " Phan tu lon nhat la: " << max << endl;
- getch();
- }
- #include<stdio.h>
- #include<conio.h>
- int a[100];
- void main()
- {
- int i, n, max, min;
- printf("nhap so phan tu cua mang: ");
- scanf("%d", &n);
- for (i = 0; i < n; i++)
- {
- printf("nhap phan tu thu %d: ", i + 1);
- scanf("%d", &a[i]);
- }
- max = a[0]; min = a[0];
- for (i = 0; i < n; i++)
- {
- if (min > a[i])min = a[i];
- if (max < a[i])max = a[i];
- }
- printf("phan tu nho nhat la: %d\n", min);
- printf("phan tu lon nhat la: %d\n", max);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement