Takanori Oshiro
unread,Jul 7, 2021, 7:54:07 AM7/7/21You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
In order to record balance sheet on android terminal
tiny calculator becomes to be needed
Please refer to source code about detail
#include <stdio.h>
#include <stdlib.h>
int main(){
char buf[80];
char operator;
char str1[80];
char str2[80];
int datum1;
int datum2;
int i,j;
while(1){
i=j=0;
scanf("%s",buf);
while(buf[i] != '+' && buf[i] !='-')
str1[j++]= buf[i++];
str1[j+1] = '\0';
operator = buf[++i];
j=0;
while(buf[i]!='\0')
str2[j++]=buf[i++];
str2[j+1]='\0';
datum1 = atoi(str1);
datum2 = atoi(str2);
if(operator=='+')
printf("%d\n",datum1+datum2);
else
printf("%d\n",datum1-datum2);
}
}