คำตอบที่ได้รับเลือกจากเจ้าของกระทู้
ความคิดเห็นที่ 1
ซึ่งผมเขียนได้เป็น
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
char text[255];
char ch;
int count;
int i,j,lent;
i=0;
printf("Input : ");
gets(text);
strlwr(text);
lent = strlen(text);
while(i<lent)
{
ch = text;
if(ch != ' ')
{
count = 0;
for(j=i;j<lent;j++)
{
if(ch==text[j])
{
count++;
text[j]= ' ';
}
}
printf("%c = %d\n",ch,count);
}
i++;
}
}
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
char text[255];
char ch;
int count;
int i,j,lent;
i=0;
printf("Input : ");
gets(text);
strlwr(text);
lent = strlen(text);
while(i<lent)
{
ch = text;
if(ch != ' ')
{
count = 0;
for(j=i;j<lent;j++)
{
if(ch==text[j])
{
count++;
text[j]= ' ';
}
}
printf("%c = %d\n",ch,count);
}
i++;
}
}
แสดงความคิดเห็น
รบกวนขอคำเเนะนำ โจทย์ข้อนี้หน่อยคับ!!!!!!!
จะแสดงผล ดังนี้ ให้คิดวิธีการเองว่าจะทำอย่างไรเพื่อให้สามารถนับจำนวนอักษรได้โดยตัวพิมพ์เล็กหรือพิมพ์ใหญ่เช่น P กับ p ให้ถือว่าเป็น ตัวอักษiเดียวกัน ถ้าเป็นอักขระอื่นที่ไมใช่ตัวอักษรภาษาอังกฤษจะไม่นับ