标签:names return scanf %s getch fgetc out png scan
#include<iostream> #include<string.h> using namespace std; char a[80]; int sc[80]; int main() { int i, sum = 0; while (scanf("%s", a) == 1)//注意s前无&用这种方法碰到空格tab等就会结束 用getchar/fgetc(stdin) { for (i = 0; i < strlen(a); i++) { if (a[i] == ‘X‘) sc[i] = 0; else if (a[i] == ‘O‘) { sc[i] = 0; for (int n = i; n >= 0; n--) {//这里不能i=i了,否则i的值会被修改 if (a[n] == ‘O‘)sc[n]++; else break; } } } for (int i = 0; i < strlen(a); i++)cout << sc[i]; for (int i = 0; i < strlen(a); i++)sum += sc[i]; cout << sum; } return 0; }
标签:names return scanf %s getch fgetc out png scan
原文地址:https://www.cnblogs.com/ZengWeiHao/p/10392872.html