Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- double sumaszeregu(n)
- {
- int i=1;double s=0;
- for(;i<=n;++i)
- {
- s+=(double)1/i;
- }
- return s;
- }
- void main()
- {
- int n;
- for(;;)
- {
- if(scanf("%d",&n))
- if(n>=0)
- break;
- }
- printf("Dla n=%d suma=%f",n,sumaszeregu(n));
- }
- */
- void main()
- {
- int a,b;char z='a';double w=0;int czy=0;
- while(1)
- {
- fflush(stdin);
- printf("znak: ");scanf_s("%c",&z);if(z=='.')break;
- fflush(stdin);
- printf("a,b: ");scanf_s("%d%d",&a,&b);
- switch (z)
- {
- czy=0;
- case '+':
- w=a+b;
- break;
- case '-':
- w=a-b;
- break;
- case '*':
- w=a*b;
- break;
- case '/':
- if(b==0){printf("Nie mozna dzielic przez 0!\n");czy=1;break;}
- w=a/b;
- break;
- case '%':
- w=a%b;
- break;
- default:
- printf("Bledny operator\n");
- }
- if(!czy)
- printf("wynik=%g\n",w);
- }
- printf("koniec programu STOP\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement