
PrivateSub_Click()
IfText1FontName="宋体"Then
Text1FontName="黑体"
Else
Text1FontName="宋体"
EndIf
EndSub
修改字体(点击按钮,将Text1文本框中的字体样式在"黑体"和"宋体"间切换)
(如果是修改其他属性,以此类推)
只要查查相关属性值,修改还是很轻松的。
Private Sub Command1_Click()
句子 = "i like you do you like me !"
子串 = "you"
次数 = 0
位置 = 0
Do
位置 = InStr(位置 + 1, 句子, 子串)
If 位置 = 0 Then
Exit Do
Else
次数 = 次数 + 1
End If
Loop
Print "在"; 句子; "中,"; 子串; "共出现了"; 次数; "次"
End Sub
这样应该看起来比较容易阅读,也好调试点。
#include "stdioh"
int main(void){
char s[100],ns[100];
int i,j;
printf("Please intput a string\ns=");
gets(s);
for(j=i=0;ns[j]=s[i];i++)
if(s[i]<'0' ||s[i]>'9')
j++;
puts(ns);
return 0;
}
扩展资料:
ascall码第0~32号及第127号(共34个)是控制字符或通讯专用字符,如控制符:LF(换行)、CR(回车)、FF(换页)、DEL(删除)、BEL(振铃)等;
通讯专用字符:SOH(文头)、EOT(文尾)、ACK(确认)等;
第33~126号(共94个)是字符,其中第48~57号为0~9十个阿拉伯数字;65~90号为26个大写英文字母,97~122号为26个小写英文字母,其余为一些标点符号、运算符号等。
注意:在计算机的存储单元中,一个ASCII码值占一个字节(8个二进制位),其最高位(b7)用作奇偶校验位。所谓奇偶校验,是指在代码传送过程中用来检验是否出现错误的一种方法,一般分奇校验和偶校验两种。
参考资料:
百度百科-ascall码
#include<stdioh>
main()
{char s[99],c;
int i=0,n=0;
printf("输入字符串(按Enter结束):\n");
gets(s);
printf("输入字符(按Enter结束):");
c=getchar();
for(i=0;i<99;i++)
{if(c==s[i])
n++;
}
printf("字符串%s中字符%c出现%d次",s,c,n);
}
//看时间,你是用不到了,留个要学习的看吧。(字符串中可能有空格,所有不要用scanf函数for循环获取)
char string = "haha";
char string2[64] = "heihei";
字符串的处理有很多,不知道你要哪种
/原字符串/
char str[27] = {0};
/因为字符数组是指针常量
不能更改所以创建一个指针,把首地址给这个指针/
char ptr = str;
/循环变量/
int i = 0;
/你想要在哪个位置添加字母/
int num = 0;
/添加的字母名字/
char ch;
/添加后后面的字母移位时存取前一个字母的变量/
char src;
/临时转换的变量/
char tmp;
printf("enter your string!\n");
scanf("%s", &str);
/格式化输入插入的字母位置和名字/
printf("enter format: [num],[char]\n");
scanf("%d,%c", &num, &ch);
/如果num是3,则将第3个字母保存在src中/
src = (ptr + (num - 1));
/如果num是3,将要添加的字母ch放到第3个位置/
(ptr + (num - 1)) = ch;
/如果num是3则将后面的23个字母后移/
for(i=num; i<(strlen(str)-num); i++)
{
/第一次进循环将原来num位置的字母给tmp
以后每次都是将前一个字母给tmp存起来/
tmp = src;
/将循环到该位置的还未后移的原字母到src/
src = (ptr + i);
/将src保存给tmp的前一个字母放到这个位置/
(ptr + i) = tmp;
}
printf("dest: %s\n", str);
其中scanf输入的字符串不能加空格,最好不用sacnf直接给原字符串赋值
#include <stdioh>
#include <stringh>
#include <malloch>
int main()
{
char str1 = (char)malloc(sizeof(char) 100);
char str2 = (char)malloc(sizeof(char) 100);
char str3 = (char)malloc(sizeof(char) 200);
gets(str1);
gets(str2);
strcpy(str3, str1);
strcat(str3, str2);
puts(str3);
free(str1);
free(str2);
free(str3);
return 0;
}
i/10000 这样是两个整数相除,i<10000时结果都是0
改i/100000 有浮点数参加运算才能得到小数,后面的都要改一下
read>>wenben[10000]; 这里写错了,应该是:
read>>wenben;
还有enter<<wenbenf[10000];
enter<<wenbenf;
#include
<stdioh>
#include<stringh>
#include<stdlibh>
struct
STKY
{
char
keyword[100];
int
count;
float
frq;//出现频率
struct
STKY
next;
}h;//带头结点的单链表,头结点h->count中保留了句子中的单词个数,其他节点count保存的是keyword出现的次数
int
AddList(struct
STKY
h,char
szText)
{
struct
STKY
p,q;
char
szTemp[50]={0};
int
i=0,j=0;;
h->count=1;
while(szText[i])
{
if(szText[i]!='
')
szTemp[j++]=szText[i];
else
{
h->count++;
szTemp[j]='\0';
p=q=h;
if(p->next==NULL)
{
p=(struct
STKY)malloc(sizeof(struct
STKY));
p->next=NULL;
strcpy(p->keyword,szTemp);
p->count=1;
q->next=p;
p=q;
}
else
{
p=q=h->next;
while(p)
{
if(strcmp(p->keyword,szTemp)==0)
{
p->count++;
break;
}
q=p;
p=p->next;
}
if(p==NULL)
{
p=(struct
STKY)malloc(sizeof(struct
STKY));
p->next=NULL;
strcpy(p->keyword,szTemp);
p->co
#include
<stdioh>
#include<stringh>
#include<stdlibh>
struct
STKY
{
char
keyword[100];
int
count;
float
frq;//出现频率
struct
STKY
next;
}h;//带头结点的单链表,头结点h->count中保留了句子中的单词个数,其他节点count保存的是keyword出现的次数
int
AddList(struct
STKY
h,char
szText)
{
struct
STKY
p,q;
char
szTemp[50]={0};
int
i=0,j=0;;
h->count=1;
while(szText[i])
{
if(szText[i]!='
')
szTemp[j++]=szText[i];
else
{
h->count++;
szTemp[j]='\0';
p=q=h;
if(p->next==NULL)
{
p=(struct
STKY)malloc(sizeof(struct
STKY));
p->next=NULL;
strcpy(p->keyword,szTemp);
p->count=1;
q->next=p;
p=q;
}
else
{
p=q=h->next;
while(p)
{
if(strcmp(p->keyword,szTemp)==0)
{
p->count++;
break;
}
q=p;
p=p->next;
}
if(p==NULL)
{
p=(struct
STKY)malloc(sizeof(struct
STKY));
p->next=NULL;
strcpy(p->keyword,szTemp);
p->count=1;
q->next=p;
p=q;
}
}
j=0;
}
i++;
}
////////////////////计算出现频率
p=q=h->next;
if(p==NULL)
return
1;
while(p)
{
p->frq=(float)(p->count10/h->count);
p=p->next;
}
return
0;
}
int
main()
{
char
szText[1024]="good
morning
just
have
a
good
breakfast
";//测试的字符串
char
szFormat[1024]={0};
int
i=0,j=0;
int
iPrev=0;
struct
STKY
p;
while(szText[i])
{
if(szText[i]!='
')
{
szFormat[j++]=szText[i];
iPrev=0;
}
else
{
if(iPrev==0)
szFormat[j++]=szText[i];
iPrev=1;
}
i++;
}
if(szFormat[j-1]=='
')
szFormat[j-1]='\0';
puts("处理前的字串:");
puts(szText);
strcpy(szText,szFormat);
puts("处理后的字串:");
puts(szText);
////////////////////////////////////////////
h=(struct
STKY)malloc(sizeof(struct
STKY));
h->next=NULL;
AddList(h,szText);
p=h->next;
puts("计算出的单词出现频率");
while(p)
{
printf("%s:\n%f\n",p->keyword,p->frq);
p=p->next;
}
return
0;
}
展开
以上就是关于在vb程序中,怎么设计一个设置字符格式的程序全部的内容,包括:在vb程序中,怎么设计一个设置字符格式的程序、求vb字符串处理的程序代码,怎么做、C语言程序设计 从键盘输入一个字符串,将其中所有的数字字符抽出,按原顺序组成一个新串并输出。等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)