1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include<conio.h>
#include<stdio.h>
double a[200],b;
int i,n,vtri;
void size ()
{
printf("\n put size array : ");
scanf("%d",&n);
}
void array ()
{
printf("\n put data \n");
for(i = 0 ; i < n ; i++)
{
printf("\n a[%d] = ",i+1);
scanf("%lf",&a[i]);
}
printf("\n array before insert \n");
for(i = 0 ; i < n ; i++)
printf("%2.2lf\t",a[i]);
}
void insert ()
{
int j;
printf("\n put location yo want insert : ");
scanf("%d",&vtri);
vtri=vtri-1;
printf("\n put data : ");
scanf("%lf",&b);
for( i = 0 ; i < n ; j++)
for( j = i+1 ; j < n ; j++)
for(i = n ; i > vtri ; i--)
{
a[i] = a[j];
a[vtri] = b;
}
n++;
printf("\n array after insert \n");
for(i = 0 ; i < n ; i++)
printf("%2.2lf\t",a[i]);
}
main()
{
size();
array();
insert();
printf("\n");
getche();
}
|
but code run not true,please help me !! thank !
Last edited on
Could you please elaborate more on what you're trying to do? What do you mean by 'code run not true'?
Also, is there a reason you're using printf and scanf instead of cout and cin? The latter two are C++ functions - the former are C.
Might consider formatting your code a little better for readability as well. Looks like the copy/paste didn't keep formatting.