title
https://pintia.cn/problem-set.
related codes
-sharpinclude <stdio.h>
-sharpinclude <string>
-sharpinclude <iostream>
using namespace std;
int read()
{
char ch = getchar();
int f = 1;
int x = 0;
while (ch < "0" || ch > "9") { if (ch == "-")f = 0; ch = getchar(); }
while (ch >= "0" && ch <= "9") { x = x * 10 + ch - "0"; ch = getchar(); }
return f ? x : x * -1;
}
int main()
{
char c;
// scanf("%c\n",&c); // scanf cin+getchar
cin >> c;
getchar();
string s;
getline(cin,s);
if(c == "C")
{
for(int i = 0;i < s.length();)
{
int count = 0;
char t = s[i];
while(s[i] == t)
{
i PP;
count PP;
}
if(count != 1)
{
printf("%d",count);
}
printf("%c",t);
}
}
else
{
for(int i = 0;i < s.length();i PP)
{
if(s[i] >= "0" && s[i] <= "9")
{
int temp = 0;
while(s[i] >= "0" && s[i] <= "9")
{
temp = temp * 10 + s[i] - "0";
i PP;
}
for(int j = 0;j < temp;j PP)
{
printf("%c",s[i]);
}
if(temp == 0)
{
printf("%c",s[i]);
}
}
else
{
printf("%c",s[i]);
}
}
}
printf("\n");
return 0;
}
what result do you expect? What is the error message actually seen?
I don"t quite understand what metaphysics this is. After asking several people, they all said it was the same. At first, I found a blog with a format error-wa on the Internet like me. But it doesn"t say why. Later, after reading several problem solutions, I tried to change scanf into cin. What"s the difference between scanf ("% cn") and cin+getchar? don"t they all end up eating newline characters in order to read a line string
?update: I tried to change it to scanf ("% c", & c); + getchar (); can ac the title. I want to know the n in scanf ("% cn", & c). My original intention is to use it to read line breaks. Can"t I read it
?