Hirdetés
- iPhone topik
- Xiaomi 15T - reakció nélkül nincs egyensúly
- Xiaomi 14T Pro - teljes a család?
- Poco X6 Pro - ötös alá
- EarFun Air Pro 4+ – érdemi plusz
- Megérkezett a Google Pixel 7 és 7 Pro
- Milyen okostelefont vegyek?
- Az iPhone 17 gáncsolta el a Galaxy S26 Prót?
- Mobil flották
- Apple iPhone 17 Pro Max – fennsík
Ú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!
- Windows, Office licencek kedvező áron, egyenesen a Microsoft-tól - Automata kézbesítés utalással is!
- DOKKOLÓ BAZÁR! Lenovo, HP, DELL és egyéb más dokkolók (TELJES SZETTEK)
- 156 - Lenovo LOQ (15IRH8) - Intel Core i5-13505H, RTX 4060
- Bomba Ár! Lenovo ThinkPad E14 G2 AMD - Ryzen 5 I 8GB I 256SSD I 14" FHD I HDMI I W11 I Gari
- Samsung Galaxy S24 FE 128GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest


