一直搞输入啊搞输入搞不出来,搜题解,然后突然发现可以这样输入, 简单多了, 语言基础没学好?
代码:
#include <cstdio>
#include <queue>
#include <cstring>
#include <iostream>
#include <vector>
#include <cctype>
using namespace std;
vector <int> v;
vector <int>::iterator it;
char s[1000];
int maps[50][500];
int main()
{
int n, m = 0, maxn = 0;
cin >> n;
int t;
char ch;
getchar();
for(int i = 1; i <= n; i ++)
{
int j = 0;
scanf("%d%c", &t, &ch);
maps[i][++j] = t;
m = max(m, j);
maxn = max(maxn, t);
while(ch == ',')
{
ch = ' ';
scanf("%d%c", &t, &ch);
maps[i][++j] = t;
maxn = max(maxn, t);
m = max(m, j);
}
}
printf("%d\n", maxn);
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= m; j ++)
{
if(maps[i][j] == maxn)
{
v.insert(v.end(), i);
break;
}
}
}
bool first = 1;
for(it = v.begin(); it != v.end(); it ++)
{
if(first)
{
printf("%d", *it);
first = 0;
}
else printf(",%d",*it);
}
return 0;
}
顺便存一下注掉的……(为什么要存这个……
/* char t = getchar();
int j = 0;
int i = 1;
while(i <= n)
{
int a = 0;
char ch = getchar();
while(1)
{
while(isdigit(ch))
{
a *= 10;
a += ch-'0';
ch = getchar();
}
maps[i][++j] = a;
if(ch != ',')
break;
}
i ++;
}
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= 10; j ++)
cout << maps[i][j] << " ";
cout << endl;
}*/