1. C语言源程序
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,i,j,k; //定义整形变量;
printf("Input n:");
scanf("%d",&n); //把你输的数读入n中;
if(n==1)
{
printf("A\n"); //如果n=1,输出A;
}
else
{
k=2*(n-1); //否则, k=2*(n-1);
for(i=0;i<n;i++) //外循环
{
for(j=0;j<k;j++) //内循环;
{
printf(" "); //输出空格专;
}
k-=2; //k=k-2;
for(j=0;j<i;j++)
{
printf("%c ",'A'+j); //输出‘属A’+j;j=1时 ,输出B,用的是ASC码;
}
for(j=i-2;j>=0;j--)
{
printf("%c ",'A'+j); //同上
}
printf("\n");
}
}
system("pause");
}
懂了吗??
2. 编写一个完整的c语言源程序
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAXTYPE 4
enum { LOW, UP, DIGIT, OTHER };
int count[MAXTYPE];
float percent[MAXTYPE];
int CharTypeCount(char *s)
{
unsigned char *p;
int i;
int n;
memset(count, '\0', sizeof(count));
p = (unsigned char*)s;
n = 0;
while (*p) {
if (*p>='a' && *p<= 'z') {
count[LOW]++;
}
else if (*p>='A' && *p<= 'Z') {
count[UP]++;
}
else if (*p>='0' && *p<= '9') {
count[DIGIT]++;
}
else {
count[OTHER]++;
}
p++;
n++;
}
for (i=0; i<MAXTYPE; i++) {
percent[i] = (count[i]*1.0)/n;
}
return n;
}
int main()
{
char s[1000];
int i;
int n;
while(gets(s) != NULL) {
n = CharTypeCount(s);
if (n <=0 ) {
printf("please input a string!\n");
continue;
}
printf("a-z: %d/%d %.2f%%\n", count[LOW], n, percent[LOW]);
printf("A-Z: %d/%d %.2f%%\n", count[UP], n, percent[UP]);
printf("0-9: %d/%d %.2f%%\n", count[DIGIT], n, percent[DIGIT]);
printf("OTHER: %d/%d %.2f%%\n", count[OTHER], n, percent[OTHER]);
}
return 0;
}
3. 求16点阵专用汉字库的建立和显示c语言源程序
小朋友,自己写