Advertisement
gacnvnmovie

156

Nov 17th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. // Bai 156.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stdio.h"
  6. #include "conio.h"
  7. #include "math.h"
  8. void nhap( int a[], int &n)
  9. {
  10.     printf("nhap so phan tu ");
  11.     scanf("%d",&n);
  12.     for (int i=0;i<n;i++)
  13.     {
  14.         printf("Nhap a[%d]: ",i);
  15.         scanf("%d",&a[i]);
  16.     }
  17. }
  18. void xuat( int a[],int n)
  19. {
  20.     for (int i=0;i<n;i++)
  21.     {
  22.         printf("a[%d]:%d ",i,a[i]);
  23.     }
  24. }
  25. void xuly( int a[],int n,int m)
  26. {
  27.     int gt[100],x;
  28.     for (int i=0;i<n;i++)
  29.     {
  30.         for (int j=0;j<n;j++)
  31.         {
  32.             x=a[i]-m;
  33.             gt[j]=abs(x);
  34.         }
  35.     }
  36.     for (int j=0;j<n;j++)
  37.     {
  38.         printf("gt[%d]:%d ",j,gt[j];
  39.     }
  40. }
  41.        
  42. void main()
  43. {
  44.     int a[100],n,m;
  45.     nhap(a,n);
  46.     xuat(a,n);
  47.     printf("nhap vao m ");
  48.     scanf("%d",&m);
  49.     xuly(a,n,m);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement