/////////////////////////////////////////////////////////////////THIEM XOA CHUOI//////////////////////////////////////////////////////////////////////////////
#include<iostream>
using namespace std;
#include<stdio.h>
#include<string.h>
/*inline void xoa(int *a,int &n,int vt)
{
for(int i=vt+1;i<n;i++)
{
a[i]=a[i-1];
}
n--
}
inline void them(int *a,int &n, int vt, int pt)
{
for(int i=n-1;i>=vt;i--)
{
a[i]=a[i+1];
}
a[vt]=pt;
n++;/*
}
*/
//xoa chuoi
inline void xoa(char *s,int vt)
{
int n=strlen(s);
for(int i=vt;i<n;i++)
{
s[i+1]=s[i];
}
s[n-1]='\0';
}
inline void them(char *s,int vt,char pt)
{
int n=strlen(s);
for(int i=n-1;i>=vt;i--)
{
s[i+1]=s[i];
}
s[vt]=pt;
//s[n+1]='\0';
}
int main()
{
char s[]="chucdeptrai";
xoa(s,4);
printf("\n%s",s);
them(s,3,'tr');
printf("\n%s",s);
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.