Új hozzászólás Aktív témák
-
válasz
rothkrisz #482 üzenetére
Hali!
A progi CodeBlocksban íródott. Bár írtad, hogy most kezdtél C-ben írni, de ennak ellenére úgy írtam, hogy legyen bent valami "újdonság" is, ami hasznos. Nézd át, ha valami nem tiszta írj.
Fire.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char str[255];
unsigned char ndx[10];
int i,j,maxndx;
for(i=0;i<sizeof(ndx);ndx[i]=0, i++);
printf("Enter numbers (0-9): ");
gets(str);
for (i=0;i<strlen(str);i++) {
if (str[i]<'0' || str[i]>'9') {
printf("Illegal char found, skipped.. -> %c\n",str[i]);
continue;
};
ndx[str[i] & 0x0f]++;
}
//Horizontal
for(i=0;i<sizeof(ndx);i++) {
printf("\n%c ",i+'0');
for (j=ndx[i];j>0;j--) { printf("*"); }
}
printf("\n\n\n");
//Vertical
for(i=0, maxndx=0;i<sizeof(ndx);i++) {
maxndx=ndx[i]>=maxndx ? ndx[i] : maxndx;
}
for(;maxndx>0;maxndx--) {
for(i=0;i<sizeof(ndx);i++) {
ndx[i]<maxndx ? printf(" ") : printf("*");
}
printf("\n");
}
for(i=0;i<sizeof(ndx);printf("%c",'0'+i),i++);
printf("\n");
return 0;
}
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- Garanciális MSI Katana GAMER 15,6"240Hz!i5 12500H(16X4,5Ghz)RTX 3060 6 GB VGA,32-64GB RAM/1TB SSD
- Bivaly MAGYAR Lenovo P1 gen2 (Core I7 32 Gb 1Tb 15" 4K 4Gb Nvidia) Laptopom eladó!!!
- HP ProBook 640 G8, 14" FHD IPS Touch, I5-1145G7 CPU, 16GB DDR4, 256GB SSD, WIN 11
- HP ProBook 640 G8, 14" FHD IPS Touch, I5-1145G7 CPU, 16GB DDR4, 256GB SSD, WIN 11
- HP ProBook 450 G7, 15,6" FHD IPS, I5-10210U CPU, 16GB DDR4, 256GB SSD, WIN 11
- ÁRGARANCIA!Épített KomPhone Ryzen 7 5800X 32/64GB RAM RTX 4060 Ti 8GB GAMER PC termékbeszámítással
- Apple iPhone 14 128GB, Kártyafüggetlen, 1 Év Garanciával
- ROBUX ÁRON ALUL - VÁSÁROLJ ROBLOX ROBUXOT MÉG MA, ELKÉPESZTŐ KEDVEZMÉNNYEL (Bármilyen platformra)
- ÁRGARANCIA!Épített KomPhone i5 12400F 16/32/64GB RAM RTX 4060 8GB GAMER PC termékbeszámítással
- Bomba ár! Lenovo ThinkPad T490s - i5-8GEN I 16GB I 512SSD I 14" FHD I Cam I W11 I Gari!
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: Promenade Publishing House Kft.
Város: Budapest