Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Kovacik Michal
- //pisomna praca
- #include <stdio.h>
- void vykresli_vzor(int r, int c, int *p_bodka, int *p_cislica);
- int main(){
- int p, r, c, bodka, cislica;
- scanf("%d", &p);
- for (; p > 0; p--){
- bodka = 0;
- cislica = 0;
- scanf("%d %d", &r, &c);
- vykresli_vzor(r, c, &bodka, &cislica);
- printf("V zadanom vzore je: %d znakov .\n", bodka);
- printf("V zadanom vzore sa cislica %d vyskytuje %d krat\n", c, cislica);
- }
- return 0;
- }
- void vykresli_vzor(int r, int c, int *p_bodka, int *p_cislica){
- int i, j, k, predbodky;
- for (i = 0; i < r; i++){
- predbodky = 0;
- for (j = 1; j < 2 * r; j++){
- if ((j <= i) || (j + i >= 2 * r)){
- putchar('.');
- *p_bodka += 1;
- predbodky++;
- }
- else{
- printf("%d", (r - i + j - 1 - predbodky) % 10);
- if ((r - i + j - 1 - predbodky) % 10 == c)
- *p_cislica += 1;
- }
- }
- putchar('\n');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement