Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //2. priklad
- #include <stdio.h>
- int main(){
- double a, b, c;
- scanf("%lf %lf %lf", &a, &b, &c);
- printf("%d %d %d %.2lf", (int)(a), (int)(b), int(c), (a+b+c)/3);
- return 0;
- }
- //3.priklad
- #include <stdio.h>
- #define M 3
- #define N 2
- int main(){
- int d, i, j, k, l;
- scanf("%d", &d);
- if (d<1 || d>15 || !(d%2)){
- printf("Zly vstup\n");
- return 1;
- }
- for(k=1; k<=M; k++){
- for(i=1; i<=d/2+1; i++){
- for(l=1; l<=N; l++){
- for(j=1; j<=d/2+1; j++){
- if(j<=i)
- putchar('*');
- else
- putchar('-');
- }
- }
- putchar('\n');
- }
- for(; i<=d; i++){
- for(l=1; l<=N; l++){
- for(j=1; j<=d/2+1; j++){
- if(j<=i-(d/2+1))
- putchar('-');
- else
- putchar('*');
- }
- }
- putchar('\n');
- }
- }
- return 0;
- }
- //4.priklad
- #include <stdio.h>
- int main() {
- char c;
- int male=0, velke=0;
- while((c=getchar())!='\n'){
- if(c>='a' && c<='z')
- male++;
- if(c>='A' && c<='Z')
- velke++;
- }
- printf("%d %d\n", male, velke);
- return 0;
- }
- //5.priklad
- #include <stdio.h>
- #include <math.h>
- int main(){
- float f, g;
- int i;
- scanf("%f %f", &f, &g);
- i=(int)(ceil(f));
- for(; i<(int)(floor(g)); i++){
- if (!(i%3)){
- printf("%d ", i);
- i +=2;
- }
- }
- putchar('\n');
- return 0;
- }
- //6.priklad
- #include <stdio.h>
- int policko(char znak, int rozmer);
- int main(){
- int p, n, i, j, k;
- scanf("%d %d", &n, &p);
- for (i = 1; i <= n; i++){
- for (k = 1; k <= p; k++){
- for (j = 1; j <= n; j++){
- if (((i % 2) && (j % 2)) || (!(i % 2) && !(j % 2)))
- policko('*', p);
- else
- policko(' ', p);
- }
- putchar('\n');
- }
- }
- return 0;
- }
- int policko(char znak, int rozmer){
- for (; rozmer >= 1; rozmer--){
- putchar(znak);
- }
- return 0;
- }
- //7.priklad
- #include <stdio.h>
- int main(){
- int n, flag = 1, pred, akt;
- scanf("%d", &n);
- scanf("%d", &akt);
- if (akt > 10 || akt<0)
- flag = 0;
- pred = akt;
- for (; n > 1; n--){
- scanf("%d", &akt);
- if (flag){
- if ((akt > 2 * pred) || (2 * akt < pred))
- flag = 0;
- pred = akt;
- }
- }
- printf("Postupnost %s spravna\n", (flag) ? "je" : "nie je");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement